Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2878

Re: How to get latest transaction date?

$
0
0

Hi,

 

You need to create a derived table in the data foundation like this:

SELECT

  A.Customer,

  Max(A.Last_Transaction_Date) as Last_Transaction_Date,

  Sum(Amount) as Amount

FROM My_Table B,

  (SELECT Customer, Last_Transaction_Date

  FROM My_Table

  WHERE

  Last_Transaction_Date  BETWEEN  @Prompt('Start Date','D')  AND  @Prompt('End Date','D')

  GROUP BY

  Customer,

  Last_Transaction_Date) A

  Where B.Customer = A.Customer And B.Last_Transaction_Date = A.Last_Transaction_Date

  GROUP BY  A.Customer

 

 

Then in the Business, Layer you create objects Customer,, Last Transaction Date and Amount based on the derived table.

 

And you will have only one row for a customer corresponding to the Max Last_Transaction_Date including on the dates range selected in the 2 @Prompt.

 

Didier


Viewing all articles
Browse latest Browse all 2878

Trending Articles