Tuesday, 8 May 2012

Sql Server material 16


-WAQ to find the details of employees whose job is CLERK.
Sol: SELECT * FROM EMP WHERE JOB=’CLERK’

-WAQ to find the details of all employees except SALESMAN.
Sol: SELECT * FROM EMP WHERE JOB != ‘SALESMAN’
(OR)
Sol: SELECT * FROM EMP WHERE JOB <> ‘SALESMAN’

-WAQ to find the details of employees who are earning more than 3000
Sol: SELECT * FROM EMP WHERE SAL>3000

-WAQ to find the details of employees who are earning less than 2500
Sol: SELECT * FROM EMP WHERE SAL<2500

-WAQ to find the details of employees who are earning with in a range of 2500 and 4000
Sol: SELECT * FROM EMP WHERE SAL>=2500 AND SAL<=4000
Sol: SELECT * FROM EMP WHERE SAL BETWEEN 2500 AND 4000

-Between operator is used for specifying with a range of values to test.

-WAQ to find the details of employees who are earning less than 1500 as well as more than 3500
Sol: SELECT * FROM EMP WHERE SAL<1500 OR SAL>3500
Sol: SELECT * FROM EMP WHERE SAL NOT BETWEEN 1500 AND 3500

<<< Previous                                                                                                                        Next >>>

No comments:

Post a Comment