SQL QUERIES
SQL QUERIES
Ending in a,e,i,o,u
select distinct city from Station where city RLIKE '.*[aeiou]$'
USING
select * from table1_name join table2_name using(column_name);
ON
select * from table1_name from table2_name on table1.coulmn=table2.coulmn;
Select max(salary) from emp_table where salary < (select max(salary) from emp_table.
(has 4 underscores)
11. Display names of all employees whose name contains i)second letter as L ii)fourth
letter as M.
.
12. Display emp names and hires dates for emps who joined in the month of December.
https://www.w3resource.com/sql-exercises/employee-database-
exercise/sql-employee-database-exercise-18.php?passed=passe
d
SELECT *
FROM employees
CORRECT ANSWER
15. Display employees whose name starts with J and ends with S.
LIMIT 2 OFFSET 10
OR
17. If they ask to display all the columns
SELECT t.*
FROM Customers t
Table 1
Table 2
20. Union all - duplicate values will not be deleted
21. INNER JOINS
TABLE1 - EMP
TABLE 2 -DEPT
22. USING ALIAS
23. Display employees who are working in Location Chicago from Emp and Dept table.
Select* from emp where deptno in (Select deptno from dept where loc = ‘CHICAGO’)
24. Display dept name with total salaries.
https://www.youtube.com/watch?v=-t6tjGtQ7-8&list=PLqM7alHXFySGweLxxAdBDK
1CcDEgF-Kwx&index=10
26. Display managers of each employee.
27. Display employee details who are getting more salary than their managers.
(if you want to display emp sal add e1.sal and if u want to display manager sal add
e2.sal)
(7*4 = 28 rows)
38. Where condition added (chicago only 1 row in dept table hence multiplied with 7
rows of emp table so o/p = 7 rows)
`
46.
https://www.youtube.com/watch?v=-6v7ctxC7yk&list=PLqM7alHXFySGweLxxAdBD
K1CcDEgF-Kwx
More references :
http://www.mithunashok.com/2011/08/sql-interview-questions-on-functions.html