Powered By Blogger

Tuesday, June 10, 2014

SMALL AND SOME USEFUL QUERIES


SQL


1)Write a query to list all the employees who are working as clerk
   SELECT * FROM EMP WHERE JOB = 'CLERK'

2) Write a query to list the employees who are working as clerks or managers with        the minimum salary of 4000
   SELECT * FROM EMP WHERE (JOB = 'CLERK' OR JOB = 'MANAGER' ) AND SAL > 4000

3) Write a query to get the current date
   SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY1

4) Write a query o list the employees who are having experience more than 4 years
   SELECT * FROM EMP WHERE YEAR(CURRENT DATE) - YEAR(HIREDATE) > 4

5) Write a query to list the employees who hired in the last seven days
    SELECT * FROM EMP WHERE DAYS(CURRENT DATE) - DAYS(HIREDATE) <= 7

No comments:

Post a Comment