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)
 Query Question

Author  Topic 

mikew
Starting Member

1 Post

Posted - 2004-07-19 : 17:34:57
Hello,

I have data in a tble (tblModStatus)

ID (int) Addr (25) ModDate (datetime)

1, 100 XI St, 2/12/2004
3, 1234 Bilbo Crt, 2/2/2004
2, 2345 Sloth Rd, 3/12/2004
1, 100 XI St, 6/6/2004
3, 1234 Bilbo Crt, 4/5/2004

I want to return:
1, 100 XI St, 3/12/2004
2, 2345 Sloth Rd, 3/12/2004
3, 1234 Bilbo Crt, 4/5/2004

Thanks,
Mike

How do I write the query to return the desired results?
Yes, this is a bad table design.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-07-19 : 17:39:24
I think your result set is messed up (first row's date should be 6/6/2004, I think). Is this what you want?:

SELECT ID, Addr, MAX(ModDate)
FROM tblModStatus
GROUP BY ID, Addr

Tara
Go to Top of Page
   

- Advertisement -