Hi All,
New to the forum and to SQL.
I'm running a query to pull sales records for a specific customer that returns several dates (for each transaction). I only need the most recent date from the results however and am having difficulty figuring out how to get this.
Can anyone help?
Thanks
Current code is:
Resulting in:
These are individual transactions of purchases of one of our books. I need these individual transactions but in the end only need the most recent date (last time they purchased.)
New to the forum and to SQL.
I'm running a query to pull sales records for a specific customer that returns several dates (for each transaction). I only need the most recent date from the results however and am having difficulty figuring out how to get this.
Can anyone help?
Thanks
Current code is:
Code:
SELECT vw_Summary_sales_Cust_Region_Brick_All.ISBN13, Sum(vw_Summary_sales_Cust_Region_Brick_All.NET_U) AS 'Sum of NET_U', vw_Summary_sales_Cust_Region_Brick_All.DOC_DATE FROM Staging_vista.dbo.vw_Summary_sales_Cust_Region_Brick_All vw_Summary_sales_Cust_Region_Brick_All WHERE (vw_Summary_sales_Cust_Region_Brick_All.CUST='56879') AND (vw_Summary_sales_Cust_Region_Brick_All.PERIOD>='0502' And vw_Summary_sales_Cust_Region_Brick_All.PERIOD<='0911') GROUP BY vw_Summary_sales_Cust_Region_Brick_All.ISBN13, vw_Summary_sales_Cust_Region_Brick_All.DOC_DATE
Code:
9781579905507 Altered Art 6,996 11/17/2006 9781579905507 Altered Art 1,804 8/24/2006 9781579905507 Altered Art 1,408 8/1/2006 9781579905507 Altered Art 638 9/28/2006 9781579905507 Altered Art 154 7/1/2008 9781579905507 Altered Art 110 7/25/2008 9781579905507 Altered Art 6 9/26/2006 9781579905507 Altered Art (2) 7/25/2007 9781579905507 Altered Art (5) 2/16/2007 9781579905507 Altered Art (8) 5/13/2008
Comment