SlashGnr
SlashGnr

Reputation: 1

Sum of values and showing in year format

SELECT datesold, SUM(salesprice) FROM Cust.trans Group By datesold;

I get this:

DateSold  Sum(SalesPrice)
12/12/08    800
18/12/08    200 
18/11/11    475
28/06/09    17500
16/03/09    450
07/06/08    2750
15/08/09    575
19/12/07    500
26/04/10    6500
27/09/10    5450
14/12/07    42500
28/09/09    400
27/09/09    400
29/09/09    68750
18/12/09    72500
28/09/12    350
18/01/08    400
28/11/08    27500
22/12/08    400

How do I change it to sum of salesprice for each year?

Upvotes: 0

Views: 19

Answers (1)

Philip Devine
Philip Devine

Reputation: 1169

This should do it.

SELECT YEAR(datesold), SUM(salesprice) FROM Cust.trans Group By YEAR(datesold);

Upvotes: 1

Related Questions