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

Aggregate help

Status
Not open for further replies.

Hollymc

Vendor
Apr 18, 2005
7
CA
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
 
Never mentioned what I would like to have happen... :)

I would like for the second query, the individual one to report purchase amount return amount
purchase amount return amount
purchase amount return amount
instead of
purchase null null null
null amount null null
null null return null

if it is possible. Thanks if you can help, thanks if you can try to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top