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 2008 Forums
 Transact-SQL (2008)
 Help in distinct group

Author  Topic 

kamii47
Constraint Violating Yak Guru

353 Posts

Posted - 2011-12-28 : 09:03:53
I have a following query which
SELECT distinct
ShipperApptID AS ShipperApptID,
TrackingID AS TrackingID
FROM
tblCloseOutRequest

is returning data as

111113082749 540000048459
111114082610 540000048459
111114092929 123000057890
111119131982 540000048459

What i needed is the result set should be like

111113082749 540000048459
111114092929 123000057890

that is wanted to select top record with same TrackingID

Kamran Shahid
Principle Engineer Development
(MCSD.Net,MCPD.net)

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-12-28 : 09:19:09
select min(ShipperApptID) as ShipperApptID, TrackingID from tblCloseOutRequest group by TrackingID


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

- Advertisement -