Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Monday, June 16, 2008

what is the output of select * from table where 1=2?

SELECT * FROM emp WHERE 1=2

the output of the query is "No records found" i.e returns no records

Sunday, June 15, 2008

select second highest salary from emp table

1.select second highest salary from emp table



select max(sal ) from emp where sal<(select max

(sal)from emp)




select max(sal) from emp where level=2 connect by prior

sal>sal group by level;





2.select the employee details who is having the second highest salary from emp table



select A.* from emp A where 1=(select count(distinct

B.sal) from emp B where B.sal>A.sal)




3.select second highest salary of the employee along with first highest salary from emp table



select ename,sal from

(select ename,sal from emp

order by sal desc)

where rownum <=2;