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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Min and Max - return one row

Status
Not open for further replies.

jasonhuibers

Programmer
Sep 12, 2005
290
CA
LName FName Start_Date End_Date BooksNum
Smith Joe 2010-08-31 12:01:00 AM 2010-08-31 15
Smith Joe 2010-08-31 12:01:00 AM 2010-10-26 15

Expected Output:
Smith Joe 2010-08-31 12:01:00 AM 2010-10-26 15

How can I do this using a min on Start_Date and a max on End_Date to have the expected output on one line?
 
Jason,

Can you please give us more of a selection of data (preferrably in INSERT statements) so that we can get a better idea of what you are expecting the code to do? (Please post more rows for Joe Smith and for someone else.)

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
LName FName Start_Date End_Date BooksNum
Smith Joe 2010-08-31 12:01:00 AM 2010-08-31 15
Smith Joe 2010-08-31 12:01:00 AM 2010-10-26 15

Expected Output:
Smith Joe 2010-08-31 12:01:00 AM 2010-10-26 15

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

Other possibilities:
Smith Joe 2010-02-31 12:01:00 AM 2010-08-31 15
Smith Joe 2010-08-31 12:01:00 AM 2010-10-26 15

Expected Output:
Smith Joe 2010-02-31 12:01:00 AM 2010-10-26 15
 
LName FName Start_Date End_Date BooksNum
Smith Joe 2010-02-31 12:01:00 AM 2010-06-31 15
Smith Joe 2010-03-31 12:01:00 AM 2010-07-31 15
Smith Joe 2010-08-31 12:01:00 AM 2010-08-31 15
Smith Joe 2010-02-31 12:01:00 AM 2010-10-26 15

Expected Output:
Smith Joe 2010-02-31 12:01:00 AM 2010-10-26 15

For example above I need to take the Min Start Date and the Max End Date...

However how can I put this on one line if for the min start date there are two records with 2010-02-31 and one record with a Max End Date of 2010-10-26?
 
Jason,

A "data logic" problem I see with your data is that "BooksNum = 15" on each data row. If, instead, the values of BooksNum were "15", "8", "13", and "6", respectively, how do you want the output to appear?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top