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!

Another Grouping and Self Join problem 1

Status
Not open for further replies.

hneal98

Programmer
Aug 13, 2002
1,637
0
0
US
Hi,

Hi have a table that is grouped and setup similar to this...

Dates..............................Lots.............Sets
01/01/2013 06:25:20..........1................A1
01/02/2013 04:25:20..........1................A1
01/03/2013 05:10:18..........1................A1
01/03/2013 08:15:26..........1................A2
01/03/2013 12:23:17..........2................A2
01/04/2013 08:17:22..........2................A2
01/04/2013 10:15:26..........2................A2
01/04/2013 15:02:10..........3................A3
01/05/2013 10:24:12..........3................A3
01/05/2013 18:05:06..........3................A4
01/06/2013 09:16:10..........3................A4
01/06/2013 12:09:58..........4................A4
01/06/2013 18:29:36..........4................A4

What I need is to group by Sets and then Lots, and get the min and the max date/time for each group of Sets and Lots. can this be done with SQL in a single query?

Let me know if you need more info. I know sometimes I tend to skimp on the detail.

Thank you for any help in advance.
 
What is your expected result from this data?

Borislav Borissov
VFP9 SP2, SQL Server
 
Whilst echoing bborissov's comment, can you also indicate why simple grouping and aggregate functions will not give you the required output?
Code:
SELECT [Sets], [Lots], MIN([Dates])as Earliest_Date, MAX([Dates]) as Latest_Date
FROM My_Table 
GROUP BY [Sets], [Lots]
ORDER BY [Sets], [Lots]

soi là, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top