latest Post

Basic SQL Queries Asked in Interviews for Freshers

Get all employee detail from EmployeeDetail table whose "EmployeName" start with any single character between 'd-m' 

SELECT * FROM [TABLENAME] WHERE EmployeName LIKE '[d-m]%'

select 2nd highest salary from "EmployeeTable"

SELECT TOP 1 SALARY FROM (SELECT TOP 2 SALARY FROM[TABLENAME]ORDER BY SALARY DESC)T ORDER BY SALARY ASC


Display employeename and gender as M/F.(if male/M,female/F)

SELECT EMPLOYEENAME,CASE WHEN GENDER='MALE' THEN 'M'
WHERE GENDER='FEMALE' THEN 'F' END AS [GENDER] FROM [TABLENAME]

Select all employee details with firstname not "ram","sita","hanuma"

SELECT * FROM [TABLENAME] WHERE FIRSTNAME NOT IN('ram','sita','hanuma')

select random record from a table

SELECT TOP 1 * FROM <TABLENAME> ORDER BY newiD()

write a query to calculate number of 'd' in string 'DOTNETDOTNETDOTNET'

SELECT LEN('DOTNETDOTNETDOTNET')-LEN(REPLACE('DOTNETDOTNETDOTNET','D',''))

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment