SELECT
OPERATORS
ORDER BY
AGGREGATION
GROUP BY
100

Display employee number(eno), employee name(ename), gender(gen) and 30% of salary(sal) as HRA for all the employees in EMP table

SELECT ENO,ENAME,GEN,SAL*.30 HRA

FROM EMP;

100

Display employee number(eno), employee name(ename) and city for all employees if name contains 'r'

SELECT ENO,ENAME,CITY

FROM EMP

WHERE ENAME LIKE '%r%' ;

100

Display employee name(ename) and date of joining(doj) in alphabetic order of their names

SELECT ENAME, DOJ

FROM EMP

ORDER BY ENAME;

100

Find the average salary(sal) of all employees in emp table

SELECT AVG(SAL) 

FROM EMP;

100

display average salary(sal) citywise

SELECT CITY, AVG(SAL)

FROM EMP

GROUP BY CITY;

200

Display employee number(eno), employee name(ename), gender(gen) and date of joining(doj) for employees residing(city) in Banagalore

SELECT ENO,ENAME,GEN, DOJ

FROM EMP

WHERE CITY='BANGALORE';

200

Display employee number(eno), employee name(ename) and city for all employees if city has 2nd last character as 'z'

SELECT ENO,ENAME,CITY

FROM EMP

WHERE CITY LIKE '%z_';

200

Display ename, did, sal in ascending order of did and within did in the descending order of sal

SELECT ENAME,DID,SAL

FROM EMP

ORDER BY DID, SAL DESC;

200

Find the total salary(sal) of all employees in emp table

SELECT SUM(SAL)

FFROM EMP;

200

to find city wise sum of salary(sal) and average salary(sal)

SELECT CITY, SUM(SAL), AVG(SAL)

FROM EMP

GROUP BY CITY;

300

Display employee number(eno), employee name(ename) and salary(sal) for employees having date of joining(doj) after 31st March1998 and city is Mumbai

SELECT ENO,ENAME,SAL

FROM EMP

WHERE DOJ>'1998-03-31' AND CITY='MUMBAI';

300

display rows 5 to 9 from emp table

SELECT * FROM EMP

LIMIT 4,5;

300

Display the emp table in alphabetic order of city where sal is below 30000

SELECT * FROM EMP

WHERE SAL < 30000

ORDER BY CITY;

300

Find the city, eno, and minimum salary(sal) of all employees in emp table

SELECT CITY,ENO,MIN(SAL)

FROM EMP;

300

display total number of employees for each department(did)

SELECT DID, COUNT(*)

FROM EMP

GROUP BY DID;

400

display all the data from emp table for employees having age less than 40

SELECT * FROM EMP

WHERE AGE<40;

400

Display city name without any duplicates

SELECT DISTINCT CITY

FROM EMP;


400

Display the emp table in ascending order of city(column 4) and descending order of sal(column 6)

SELECT * FROM EMP

ORDER BY 4,6;

400

Find the Oldest department id(did) in emp table

SELECT MIN(DID) 

FROM EMP;

400

Display eno, ename, maximum salary grouped city wise

SELECT CITY, ENO, ENAME, MAX(SAL)

FROM EMP

GROUP BY CITY;

500

display all data from emp table for employees having 'A' as 4th character in their names (use inbuilt function)

SELECT * FROM EMP

WHERE MID(ENAME,4,1)='L';

500

Display all data from emp table for salary(sal) in the range of 200000 and 500000 (both included)

SELECT * FROM EMP

WHERE SAL BETWEEN 200000 AND 500000;

500

Display all data from emp table for empno greater than 4 arranged in descending order of did

SELECT * FROM EMP

WHERE EMPNO>4

ORDER BY DID DESC;

500

Find the total number of employees in emp table

SELECT COUNT(*) FROM EMP;

500

Display highest employee number(eno) from emp table for each year

SELECT YEAR(DOJ), MAX(ENO)

FROM EMP

GROUP BY YEAR(DOJ);

M
e
n
u