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?
LVL 10
ClifAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
something like this could do:

select Customer, Min(Sell_Date), sum(Parts), sum(Labor), may(pay_date) from yourtable group by Customer

Open in new window

0
 
vdr1620Commented:

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
0
 
ClifAuthor Commented:
Perfect, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.