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 2000 Forums
 Transact-SQL (2000)
 using Distinct for Data and time fields

Author  Topic 

aminsam
Starting Member

6 Posts

Posted - 2004-05-19 : 01:51:47
My table have multiple record in same Date filed

When i use Distinct for return only one instance of every date,

it return all records with same date ;
------------------------------------------------
SELECT DISTINCT date, name,number,ID
FROM new_table
ORDER BY number

------------------------------------------------

2004/04/02 07:16:02 P.M , james, 0033134545,152546
2004/03/20 04:44:08 P.M , marc , 0048182569,152548
2004/03/20 04:44:08 P.M , marc , 0049285596,152589
2004/03/20 04:44:08 P.M , marc , 0081254782,168958
--------------------------------------------------

record 2 , 3, 4 have same date yet

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-05-19 : 03:59:24
DISTINCT works on a row not on an individual column. What sort of output do you want? If you want it to return only two rows, then what data do you want returned for the second row from the name, number and ID columns?

OS
Go to Top of Page

aminsam
Starting Member

6 Posts

Posted - 2004-05-19 : 04:13:31
I found the answer

DISTINCT operates on all the columns selected in the query together

Thanks
Go to Top of Page
   

- Advertisement -