How can I retrive all records of Emp those are not present in Emp1?
SELECT * FROM HR.EMP EXCEPT SELECT * FROM HR.EMP1
Find all Employee records containing the word "mit" in name and which is case insensitive.
SELECT * FROM HR.EMP WHERE UPPER(NAME) LIKE '%JOH%'
Write an SQL Query to find name of employee whose name Start with ‘A’
SELECT * FROM HR.EMP WHERE NAME like 'J%';
Write an SQL Query to find name of employee whose name has second character ‘A’
SELECT * FROM HR.EMP WHERE NAME like '_A%';
Write a SQL Query to select employees having salary greater than 10000 and less than 20000
SELECT * FROM HR.EMP WHERE SALARY BETWEEN 10000 AND 50000
Write a SQL Query to find day from given date?
SELECT DAY(GETDATE()) as 'Day';
Write a SQL Query to find month from given date?
SELECT MONTH(GETDATE()) as 'Month';
Write a SQL Query to find year from given date?
SELECT YEAR(GETDATE()) as 'Year';
For a given table find the sum of salary based on age.
We can use SUM() aggregate function to calculate the sum of salary by Age. So we can write below query to get the sum of salaries by age group.
SELECT Age, SUM(Salary) AS TotalSalary FROM dbo.Employees GROUP BY Age
For more details and example on SUM function refer SUM() function.