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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Displaying Distinct data

Author  Topic 

sudha12345
Starting Member

47 Posts

Posted - 2009-05-05 : 06:53:16
is there any keyword to display unique values in a table other than
DISTINCT.

Sudhakar

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-05-05 : 06:55:50
use row_number()

can post some sample data and output required
Go to Top of Page

malaytech2008
Yak Posting Veteran

95 Posts

Posted - 2009-05-05 : 07:02:27
That depending on the requirement. Please send sample data of your requirement.

malay
Go to Top of Page

sudha12345
Starting Member

47 Posts

Posted - 2009-05-05 : 07:04:34
quote:
Originally posted by bklr

use row_number()

can post some sample data and output required



the sample data is
1000001 1000001 1 APTripple 11/13/2008 14:52
1000001 1000001 2 virgildevice00 11/12/2008 10:56
1000001 1000001 3 LN02103D 11/13/2008 14:48
1000001 1000001 4 Plum169 11/13/2008 14:51
1000001 1000001 5 Dual41 11/12/2008 13:00
1000001 1000001 6 dually135 11/13/2008 14:49
1000001 1000001 7 singlerefic173 11/12/2008 10:28
1000001 1000001 1 APTripple 11/13/2008 14:52
1000001 1000001 2 virgildevice00 11/12/2008 10:56
1000001 1000001 3 LN02103D 11/13/2008 14:48
1000001 1000001 4 Plum169 11/13/2008 14:51
1000001 1000001 5 Dual41 11/12/2008 13:00
1000001 1000001 6 dually135 11/13/2008 14:49
1000001 1000001 7 singlerefic173 11/12/2008 10:28

the above has 14 rows in which first set is repeated
i want only the distinct data from the above.
can you guide me how can we do it with row_number()

Sudhakar
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-05 : 07:05:02
Why not DISTINCT?
*curious*


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

malaytech2008
Yak Posting Veteran

95 Posts

Posted - 2009-05-05 : 07:18:59
Webfred is right. You can use DISTINCT. Or if don't want to use it you can use UNION also.

Malay
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-05-05 : 08:03:08
You can use GROUP BY, i.e.,
SELECT col1,col2,col3,col4
FROM yourTable
GROUP BY col1,col2,col3,col4

Jim
Go to Top of Page
   

- Advertisement -