I have a table:
id, cust#, payment, date
1, cus1, 508, 2010-01-01
2, cus2, 40, 2010-01-01
3, cus1, 13, 2010-01-02
I have this for my query.
select id, cust#, payment, date group by cust#
As expected it returns the results. I need it to return each column value plus a value for the sum(payment) as totalpayments
I can’t figure it out as this only will return total for payments and not each payment amount plus the total
select id, cust#, sum(payment), date group by cust#
This is what i want in a sense even though this is not a valid query
select id, cust#, payment, sum(payment) AS totalpayments, date group by cust#
You have to use a sub-query: