Common SQL Questions
How to update a table?
UPDATE table_name
SET col_1 = value_1, column_2 = value_2
WHERE condition;update Salary
set sex = case
when sex = 'f' then 'm'
when sex = 'm' then 'f'
else sex
end;How to delete a table from a database?
DROP TABLE table_nameHow to add a column to a table?
ALTER TABLE table_name
ADD column_name datatype;How to rename a column of a table?
How to find the nth highest value in a column of a table?
Question 1: SQL Query to find the second highest salary of Employee(176. Second Highest Salary)
Question 2: SQL Query to find the third highest salary of Employee
Question 3: SQL query to find the Nth highest salary (177. Nth Highest Salary)
Question 4: SQL Query to find Max Salary from each department.
Question 5: Finding duplicate emails (182. Duplicate Emails)
Question 6: Find Customers Who Never Order
Question 7: Write an SQL Query to print the name of the distinct employee whose DOB is between 01/01/1960 to 31/12/1975.
Question 8: Write an SQL Query to find the number of employees according to gender whose DOB is between 01/01/1960 to 31/12/1975.
Question 9: Write an SQL Query to find the name of an employee whose name Start with ‘M’
Question 10: Find all Employee records containing the word "Joe", regardless of whether it was stored as JOE, Joe, or joe.
Question 11: There is a table which contains two columns Student and Marks, you need to find all the students, whose marks are greater than average marks i.e. list of above-average students.
Question 12: Write a SQL query to find the names of employees who have not been assigned to any project.
Question 13 : Create a Customer and Order Table and Connect Them
Question 14: How to get unique records from the table without using distinct keywords
Question 15: Write a SQL query to print the FIRST_NAME and LAST_NAME from Student table into single column COMPLETE_NAME.
Question 16: Employees Earning More Than Their Managers
Last updated