Link to home
Start Free TrialLog in
Avatar of Clif
ClifFlag for United States of America

asked on

Combining Rows

I have a query which, through joins and such, produces sort of the correct results.  The problem is that it produces two rows.

The results are something list this
Customer  Sell_Date  Parts  Labour  Pay_Date
12345678  05-30-11   12.34  50.00
12345678             24.56  12.50   06-02-11
98765432  05-22-11   18.23  12.50
98765432             16.19  32.00   05-26-11

Open in new window


I want to merge th rows so that I have an output like this:
Customer  Sell_Date  Parts  Labour  Pay_Date
12345678  05-30-11   36.90  62.50   06-02-11
98765432  05-22-11   34.42  44.50   05-26-11

Open in new window


I know how to do it with the numbers, but how do I get the dates to merge?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Try the Below Query.. so use this as an Outer query to get the desired results..Replace the Table Name with your query like

Select .... FROM ()X
Group By ...



SELECT Customer, MAX(Sell_date) as Sell_Date, SUM(Parts) as Parts , SUM(Labour) as Labour, Max(Pay_Date) as Pay_Date
FROM TableName
GROUP BY Customer
Avatar of Clif

ASKER

Perfect, thanks.