MS SQL Script in text format
MS SQL Script in text format
USE CREATIVE_cARS
--AND
Requirment#1 : Hi Raja, please provide the CHICAGO cars list AND new york CARS LIST
in
the CARSALES_tABLES.
Hi Bhargav, please provide the CHICAGO cars list and 2016 year LIST in
the CARSALES_tABLES.
-- OR
--NOT
--UNION
--UNION ALL
--UNION ALL: IT RETURNS THE OUTPUT OF TWO TABLES/MORE AND IT ALLOWS DUPLICATES;
--INTERSECT
INSERT INTO GM_EMLPOYEE (EID, ENAME, ESALARY, EAGE, EGENDER, EDEPT, ERATINGS)
VALUES
(1, 'John Doe', 50000.00, 35, 'Male', 'IT', 'Excellent'),
(2, 'Jane Smith', 60000.00, 32, 'Female', 'HR', 'Good'),
(3, 'Bob Johnson', 75000.00, 31, 'Male', 'Finance', 'Excellent'),
(4, 'Alice Williams', 80000.00, 33, 'Female', 'Marketing', 'Average'),
(5, 'Charlie Brown', 55000.00, 37, 'Male', 'Sales', 'Good'),
(6, 'Diana Miller', 70000.00, 36, 'Female', 'IT', 'Excellent'),
(7, 'Edward Davis', 62000.00, 34, 'Male', 'HR', 'Good'),
(8, 'Fiona Clark', 68000.00, 38, 'Female', 'Finance', 'Excellent'),
(9, 'George Wilson', 53000.00, 35, 'Male', 'Marketing', 'Average'),
(10, 'Helen Taylor', 72000.00, 33, 'Female', 'Sales', 'Good'),
(11, 'Isaac Turner', 62000.00, 28, 'Male', 'IT', 'Excellent'),
(12, 'Jessica Carter', 55000.00, 22, 'Female', 'HR', 'Good'),
(13, 'Kevin White', 68000.00, 30, 'Male', 'Finance', 'Excellent'),
(14, 'Lily Morgan', 50000.00, 24, 'Female', 'Marketing', 'Average'),
(15, 'Michael Walker', 72000.00, 26, 'Male', 'Sales', 'Good'),
(16, 'Natalie Hall', 60000.00, 29, 'Female', 'IT', 'Excellent'),
(17, 'Oliver Davis', 67000.00, 23, 'Male', 'HR', 'Good'),
(18, 'Penelope Reed', 58000.00, 27, 'Female', 'Finance', 'Excellent'),
(19, 'Quentin Adams', 53000.00, 25, 'Male', 'Marketing', 'Average'),
(20, 'Rachel Hill', 65000.00, 22, 'Female', 'Sales', 'Good'),
(21, 'Samuel Turner', 71000.00, 30, 'Male', 'IT', 'Excellent'),
(22, 'Tiffany Gonzalez', 59000.00, 28, 'Female', 'HR', 'Good'),
(23, 'Ulysses Rodriguez', 68000.00, 29, 'Male', 'Finance', 'Excellent'),
(24, 'Victoria Lopez', 54000.00, 27, 'Female', 'Marketing', 'Average'),
(25, 'William Foster', 69000.00, 24, 'Male', 'Sales', 'Good'),
(26, 'Xavier Parker', 61000.00, 26, 'Male', 'IT', 'Excellent'),
(27, 'Yvonne Stewart', 58000.00, 31, 'Female', 'HR', 'Good'),
(28, 'Zachary Reed', 70000.00, 33, 'Male', 'Finance', 'Excellent'),
(29, 'Abigail Cooper', 56000.00, 28, 'Female', 'Marketing', 'Average'),
(30, 'Benjamin Turner', 73000.00, 35, 'Male', 'Sales', 'Good');
INSERT INTO GM_EMLPOYEE (EID, ENAME, ESALARY, EAGE, EGENDER, EDEPT, ERATINGS)
VALUES
(31, 'John DAVID', 50000.00, 35, 'Male', 'IT', 'Excellent'),
(32, 'JOHNY Smith', 60000.00, 32, 'Female', 'HR', 'Good'),
(33, 'Bob Johnson', 75000.00, 31, 'Male', 'Finance', 'Excellent'),
(34, 'BOBY Williams', 80000.00, 33, 'Female', 'Marketing', 'Average'),
(35, 'CharMAN Brown', 55000.00, 37, 'Male', 'Sales', 'Good');
INSERT INTO GM_EMLPOYEE (EID, ENAME, ESALARY, EAGE, EGENDER, EDEPT, ERATINGS)
VALUES
(31, 'John KUMARREDDY ', 50000.00, 35, 'Male', 'IT', 'Excellent'),
(32, 'RAJ REDDY ', 60000.00, 32, 'Female', 'HR', 'Good'),
(33, 'Bob REDDY Johnson', 75000.00, 31, 'Male', 'Finance', 'Excellent'),
(34, 'BOBY Williams REDDY ', 80000.00, 33, 'Female', 'Marketing', 'Average'),
(35, 'REDDY CharMAN Brown', 55000.00, 37, 'Male', 'Sales', 'Good');
---BETWEEN (NUMERICS)
---BETWEEN (DATES)
SELECT * fROM CARSALES WHERE SaleDate BETWEEN '2020-01-01' AND '2024-12-31';
--CLUASES
WHERE
--GROUP BY
-- INTERVIEW QUESTION: CAN WE USE HAVING CLUASE WITH OUT GROUP BY CLUASE?
--REQUIREMENT#1: Hi Anusha, Please provide the total carsmake count which are
greater than 2000