More SQL Queries
More SQL Queries
2.Write an SQL query to get unique values of DEPARTMENT from Worker table.
3.Write an SQL query to print the FIRST_NAME and LAST_NAME from Worker table into
a single column COMPLETE_NAME. A space char should separate them.
5.Write an SQL query to get all Worker details from the Worker
table order by FIRST_NAME Ascending and DEPARTMENT
Descending.
6.Write an SQL query to get the details for Workers with the
first name as “Vipul” and “Satish” from Worker table.
5.Write an SQL query to get all Worker details from the Worker
table order by FIRST_NAME Ascending and DEPARTMENT
Descending.
6.Write an SQL query to get the details for Workers with the
first name as “Vipul” and “Satish” from Worker table.
WHERE CustomerName LIKE 'a%' Finds any values that start with "a"
WHERE CustomerName LIKE '%a' Finds any values that end with "a"
WHERE CustomerName LIKE '%or%' Finds any values that have "or" in any
position
WHERE CustomerName LIKE '_r%' Finds any values that have "r" in the
second position
WHERE CustomerName LIKE 'a_%' Finds any values that start with "a" and
are at least 2 characters in length
WHERE CustomerName LIKE 'a__%' Finds any values that start with "a" and
are at least 3 characters in length
WHERE ContactName LIKE 'a%o' Finds any values that start with "a" and
ends with "o"
8. Write an SQL query to print details of Workers with
DEPARTMENT name as “Admin”.
18. Write an SQL query to print details of the Workers whose SALARY
lies between 100000 and 500000.
19. Write an SQL query to fetch worker names with salaries >= 50000 and
<= 100000.
21. Write an SQL query to fetch the no. of workers for each department in
the descending order.
22. Write an SQL query to show only odd rows from a table.
24. Write an SQL query to show the current date and time.
Example 1:
SELECT City FROM Customer
UNION
SELECT City FROM Supplier
ORDER BY City;
Example 2:
SELECT City, Country FROM Customer
WHERE Country='India'
UNION
SELECT City, Country FROM Supplier
WHERE Country='India'
ORDER BY City;
26. INTERSECT Operator
29. Write an SQL query to show the top n (say 10) records of a table.
Following MySQL query will return the top n records using the LIMIT
method:
If n=1(Maximum),
SELECT salary FROM employee ORDER BY salary DESC LIMIT 1
If n=1(Minimum),
SELECT salary FROM employee ORDER BY salary ASC LIMIT 1
34. Write an SQL query to get the departments that have less than five
people in it.
35. Write an SQL query to show all departments along with the
number of people in there.
37. Write an SQL query to get the names of workers who earn
the highest salary.