Saturday, 7 April 2012

SQL Practice questions 2

Display the names of employees who are working as clerks,salesman or analyst and drawing a salary more than 3000?
Ans: select ename from emp where job='CLERK' OR
JOB='SALESMAN' OR
JOB='ANALYST' AND SAL>3000;

Display the names of the employees who are working in the company for the past 5 years?
Ans: select ename from emp where
to_char(sysdate,'YYYY')-to_char(hiredate,'YYYY')>=5;

Display the list of employcees who have joined the company before 30-JUN-90 or after 31-DEC-90?
Ans:  select ename from emp where hiredate < '30-JUN-1990' or hiredate
'31-DEC-90';

Display current Date?
Ans: select sysdate from dual;

Display the list of all users in your database(use catalog table)?
Ans: select username from all_users;

Display the names of all tables from current user?
Ans: select tname from tab;

No comments:

Post a Comment

Do you want to comment