Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Help!!!

Status
Not open for further replies.

tektipuser2008

Programmer
Aug 12, 2008
3
US
Using Teradata ordered analytical functions , is it possible to get the result set below. If yes, can someone please provide me with some hints or the SQL itself.
Any help with this is much appreciated.

Sample Data :

Col1 Col2

D1 K1
D2 K1
D3 K2
D3 K4
D4 K1
D5 K2

Result set :

Col1 Col2

D1 K1
D3 K2

Explanation : Since K1 is associated with D1, all other associations of K1 should be dropped, similarly since D3 is associated with K2 all other associations of D3 should be dropped.
 
select col1, col2 from foo qualify rank() over (partition by col2 order by col1, col2) =1
order by 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top