SQL QUERYS

Sql Querys

Note: Please Don't use * symbol at real time work .just for practice time only.

1) Write a query to get total salaries from Employee table

  Select Eno, Ename ,Ejob ,Esal ,Ecomm ,Esal+ISNULL(Ecomm,0) as TotalSal from Employee

2) Write a query to get Managers List from Employee table

  Select * from Employee where Ejob='Manager'

3) Write a query to get Employees List if DeptNo=10

 Select * from Employee where DeptNo=10

4) Write a query to get Employees with salary greater than 10000

 Select * from Employee where Esal > 10000

5) Write a query to get Employees with salary greater than 10000

 Select * from Employee where Esal < 10000

6) Write a query to get Employees List

  Select * from Employee

7) Write a query to get Managers and Clerks List

  Select * from Employee where Ejob='Manager' OR Ejob='Clerk'

8) Write a query to get managers list with salary greater than 16000

  Select * from Employee where Ejob='Manager' AND Esal <> 16000

9) Write a query to get Employee details except Managers

  Select * from Employee where job <> 'Manager'

10) Write a query to get Names starting with 'A'

  Select * from Employee where Ename Like 'A%'

11) Write a query to get Names ending with 'L'

   Select * from Employee where Ename Like '%L'

11) Write a query to get Names with second letter 'I'

   Select * from Employee where Ename Like '_I%'

12) Write a query to get Names not starting with 'A'

   Select * from Employee where Ename Not Like 'A%'

13) Write a query to get Names which are starting with A,B,C

   Select * from Employee where Ename Like '[A-C]'

14) Write a query to get Employes with salary between 5000 to 10000

  Select * from Employee where Esal BETWEEN 5000 AND 10000

15) Write a query to get Employes joined in the year 2012

  Select * from Employee Where EhireDate BETWEEN '01-JAN-2012' AND '31-DEC-2012'

16) Write a query to get Employes not having Commission

  Select * from Employee where Ecomm IS NULL

16) Write a query to get Employes having Commission

  Select * from Employee where Ecomm IS NOT NULL

17) Write a query to get first three records from Employes table with out using WHERE Clause or WHERE Condition

  Select Top 3 * from Employee

18) Write a query to get Names in Ascending(Alphabatical) order

  Select * from Employee ORDER BY Ename

19) Write a query to get Salaries in Ascending(MIN sal to MAX sal) Order

  Select * from Employee ORDER BY Esal

20) Write a query to get Salaries in Descending(Max sal to Min sal) Order

  Select * from Employee ORDER BY Esal DESC

21) Write a query to get Salaries based on job wise

  Select * from Employee ORDER By Ejob,Esal

22)  Write a query to get Salaries in Ascending order from the Employee with DeptNo=10

 Select * from Employee where DeptNo=10 ORDER BY Esal

23) Write a Query to get Three Highest Salaries From Employee table

 Select TOP 3 Esal from Employee ORDER BY Esal Desc

24)  Write a query to get Salaries Ascending order based on the given column Index value

  Select * from Employee ORDER BY 6

25) Write a query to get highest sal in the Employee Table

  Select MAX(Esal) from Employee
About Author: author 4 + years of Information Technology experience in understanding and analyzing the software and hardware engineering requirements, onsite and offshore management of product development. Expert work on design and development for windows,web,mobile Expert knowledge of C#,ADO.NET, ASP.Net MVC, ENTITY FRAMEWORK, LINQ,COLLECTIONS, JAVASCRIPT,AngularJs 1.0,Angular2, Jquery,Jquery-Ajax, SQL SERVER, XAML,Windows phone 8.1 Good knowledge of WCF-Restful services,WCF, WEB API-Services ,Web- Services,MIcrosoft-Azure,JUICE UI,HTML,CSS,AJAX Read More...

Join him on Google+ | Facebook | Linkedin