Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Display one of many identical items?

Author  Topic 

compact
Starting Member

1 Post

Posted - 2007-10-25 : 05:36:59
Hi

I am bringing back a large amount of data, with many entries based around several different people.

Is there any way of say
Display the first (or one) row for each new entry in the column

i.e.
NOT
Dave 1 Uk
Dave 2 Usa
Dave 5 France
George 3 UK
George 6 Ghana
Phil 2 Japan
Phil 7 America

BUT
Dave 1 UK
George 3 Uk
Phil 2 Japan


This will help me check each person with having to scroll past the hundred or so entries for each person.

cheers

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-25 : 06:00:19
See if this helps:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=89422

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-25 : 06:34:27
With SQL Server 2005

SELECT Col1, Col2, Col3 FROM (
SELECT Col1, Col2, Col3, ROW_NUMBER() OVER (PARTITION BY Col1 ORDER BY Col2) AS RecID
) AS d WHERE RecID = 1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -