Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select question 1

Status
Not open for further replies.

rajkum

Programmer
Jul 30, 2003
48
0
0
US
Hi,

I have a dataset which looks like this:

ID Seqnum Seqnum2 Date
===========================
1 0 0 1/1/2005
1 1 0 1/2/2005
1 1 1 1/3/2005
2 0 0 2/1/2005
3 0 0 1/1/2005
3 1 0 1/2/2005
4 0 0 1/2/2005

Problem: To show entire row
FOR each unique ID, unique SEQNum, max(SEQNum2) and latest DATE.


What I could do so far:
SELECT ID,Seqnum,Seqnum2,Max(Date)
GroupBY ID,Seqnum,Seqnum2


The above table has other columns I am interested in.

Thanks,
Raj.
 
Try this..

SELECT * FROM TBLNAME T1
INNER JOIN
(SELECT ID,Seqnum,Seqnum2,Max(Date) [Date]
FROM TBLNAME
Group BY [ID],Seqnum,Seqnum2) TBL ON t1.[ID] = TBL.[ID] and t1.SeqNum = TBL.SeqNum and t1.Seqnum2 = TBL.SeqNum and t1.[Date] = TB.[Date]



Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top