Monday, September 10, 2012

What are joins..how many types of joins are there?

A join is a query that extracts data from two or more tables, views or snapshots.

1. Equi Join
2.Non Equijoin
3.outer joins
4.self joins 
 

To get second highest age from the student table 

 
SELECT * FROM (SELECT s.*, rownum age_rank
 FROM (SELECT * FROM student ORDER BY age DESC) s) WHERE age_rank=2
 
 

Write a query to display alternate records from the employee table?

SELECT * FROM emp WHERE ROWID IN 
(SELECT DECODE(MOD(ROWNUM,2),0,ROWID, NULL) FROM emp);

 

 
 

No comments:

Post a Comment