1: SQL Query to find second highest salary of Employee
select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) from Employee );
2: SQL Query to find Max Salary from each department.
SELECT DeptID, MAX(Salary) FROM Employee GROUP BY DeptID.
3:Write SQL Query to display current date.
SELECT GetDate();
4:Write an SQL Query to check whether date passed to Query is date of given format or not.
SELECT ISDATE('1/08/13') AS "MM/DD/YY";
5: Write a SQL Query to print the name of distinct employee whose DOB is between 01/01/1960 to 31/12/1975.
SELECT DISTINCT EmpName FROM Employees WHERE DOB BETWEEN ‘01/01/1960’ AND ‘31/12/1975’;
6:Write an SQL Query find 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;
7:Write an SQL Query to find employee whose Salary is equal or greater than 10000.
SELECT EmpName FROM Employees WHERE Salary>=10000;
8:Write an SQL Query to find name of employee whose name Start with ‘M’
SELECT * FROM Employees WHERE EmpName like 'M%';
9: find all Employee records containing the word "Joe", regardless of whether it was stored as JOE, Joe, or joe.
SELECT * from Employees WHERE upper(EmpName) like upper('joe%');
10: Write a SQL Query to find year from date.
SELECT YEAR(GETDATE()) as "Year";
Also read: SQL Queries - Schema wise
Also read: Useful SQL Queries
Also read: SQL QUERIES ask in Interviews