Professional Documents
Culture Documents
Suggested Topic
Suggested Topic
Suggested Topic
1.Using the GROUP BY clause to group all rows by the target column(s) –
i.e. the column(s) you want to check for duplicate values on.
2.Using the COUNT function in the HAVING clause to check if any of the groups have
more
than 1 entry; those would be the duplicate values.
eg:-
2.In a table
Update "Male" into "Female" and "Female" into "Male" in Gender Column of a
table in single line query.?
UPDATE tableA
SET Gender = CASE
WHEN Gender = 'Male' THEN 'Female'
ELSE 'Male'
END
select max(salary) from employee where salary < (select max(salary) from employee);
select min(salary) from (select distinct salary from emp orderby salary desc)
where rownum<=3;
===================================
https://www.java67.com/2013/04/10-frequently-asked-sql-query-interview-questions-
answers-database.html
select deptid,max(salary)
from employee
group by deptid
3.Write an SQL Query to check whether the date passed to Query is the date of the
given format or not?
select isdate('1/05/21') as ('MM/DD/YY') --- the query will return false because it
is not in expected format
4. Write an SQL Query to print the name of the distinct employee whose DOB is
between 01/01/1960 to 31/12/1975.
select distinct(empname)
from employee
where DOB between ('01/01/1960' AND '31/12/1975');
5.Write an SQL Query to find the number of employees according to gender whose DOB
is between 01/01/1960 to 31/12/1975
-- SELECT COUNT(*), sex FROM Employees WHERE DOB BETWEEN '01/01/1960' AND
'31/12/1975' GROUP BY sex;
6. Write an SQL Query to find an employee whose salary is equal to or greater than
10000
7.Write an SQL Query to find the name of an employee whose name Start with ‘M’
8.find all Employee records containing the word "Joe", regardless of whether it was
stored as JOE, Joe, or joe.