I am running a query that finds all the clients that buy from me and return stuff within a certain range. In a range of 5 days it will give me 200 people. Now I want to see of them, who are the repeat offenders, so I wrote a new query for individual accounts. To do this I was using the MAX aggregate for the date and SUM for the amounts and it was all in one row per client like:
client purchase amount return amount
mjoan23 2005-07-05 $100 2005-07-10 $100
rdots19 2005-07-05 $120 2005-07-07 $80
etc...
query was like:
Sum( Case when operation = blah blah amount
MAX( Case when operation = blah blah date
If I take out aggregates and then plop data in the group by clause, I get: keep in mind I am looking for single clients now
client purchase amount return amount
mjoan23 2005-07-05 null null null
mjoan23 null $100 null null
mjoan23 null null 2005-07-10 null
mjoan23 null null null $100
query is like:
( Case when operation = blah blah amount
( Case when operation = blah blah date
client purchase amount return amount
mjoan23 2005-07-05 $100 2005-07-10 $100
rdots19 2005-07-05 $120 2005-07-07 $80
etc...
query was like:
Sum( Case when operation = blah blah amount
MAX( Case when operation = blah blah date
If I take out aggregates and then plop data in the group by clause, I get: keep in mind I am looking for single clients now
client purchase amount return amount
mjoan23 2005-07-05 null null null
mjoan23 null $100 null null
mjoan23 null null 2005-07-10 null
mjoan23 null null null $100
query is like:
( Case when operation = blah blah amount
( Case when operation = blah blah date