Advertisement

04.29.2008 at 10:47AM PDT, ID: 23362913
[x]
Attachment Details

SQL to Find Max Date

Asked by dev775 in MS SQL Server, C# Programming Language, SQL Query Syntax

Trying to build a SQL select statement to find a single MAX date value per customer within a group of possible values.  Have a single table CUST1 with fields CUSTID, ORDERNO, ORDERDATE, SERIES.  A customer may place many orders within several product series.  I'm trying to find a single return value for the last date the customer bought product within a specific group of product series.  The query I am using is attached.  Problem is that the query returns the MAX date for orders within each SERIES, so for each CUSTID there may be more than one record returned.  I need only one MAX date returned per CUSTID.  Also I need a WHERE clause to further filter the MAX date within a date range.
Thanks!
Start Free Trial
1:
2:
3:
4:
Select CUSTID, SERIES, max(ORDERDATE) AS LDate from CUST1
where SERIES in('A','C','D','E','L')
group by CUSTID
order by CUSTID
[+][-]04.29.2008 at 10:53AM PDT, ID: 21464491

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 11:55AM PDT, ID: 21464988

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 11:59AM PDT, ID: 21465018

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 12:08PM PDT, ID: 21465112

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 12:10PM PDT, ID: 21465129

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 12:41PM PDT, ID: 21465454

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 12:47PM PDT, ID: 21465527

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 01:08PM PDT, ID: 21465720

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 01:11PM PDT, ID: 21465759

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 01:17PM PDT, ID: 21465815

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, C# Programming Language, SQL Query Syntax
Sign Up Now!
Solution Provided By: chapmandew
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.29.2008 at 03:18PM PDT, ID: 21466689

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 03:52PM PDT, ID: 21466923

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 05:00PM PDT, ID: 21467222

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628