I am trying to join a select disinct statement to a select sum statement. Here is an example of the data
CD STDATE ENDDATE PR F1 01/02/09 01/04/09 $10 F1 01/02/09 01/04/09 $40 F1 01/02/09 01/04/09 $20 F1 01/02/09 01/04/09 $30 F1 01/22/09 01/26/09 $10 F1 01/22/09 01/26/09 $50 F1 01/22/09 01/26/09 $20
My desired output is –
F1 01/02/09 01/04/09 $100 F1 01/22/09 01/26/09 $80
So far, I have the foll statement, which is incorrect:
SELECT DISTINCT STDATE, ENDDATE, CD FROM TABLE AS A INNER JOIN (SELECT SUM(PR) FROM TABLE) AS B ON A.STDATE=B.STDATE
How can I do that???
I think you are looking for grouping: