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!

Query help

Status
Not open for further replies.

azzazzello

Technical User
Jan 25, 2005
297
US
Suppose I have a table consisting of 10 fields.

f1,f2,...,f10

f1 is not the primary key, and hence has repetitions

suppose I have

the following set of data

Code:
AAA,1,2,...
BBB,3,4,....
AAA,5,9,...
CCC,4,1,...
BBB,3,7,...

I need to return any ENTIRE row for a distinct value of f1.
So ideally my result would be

AAA,1,2,...
BBB,3,7,...
CCC,2,3,...

this can be ANY of the repeating rows, as long as there is just ONE per f1 in the resultant set
 
select f1,f2,f3,f4,f5,f6,f7,f8,f9,f10
from
(
select f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,
row_count() over(partition by f1 order by f1) rn
from t1
)
where rn = 1


In order to understand recursion, you must first understand recursion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top