In SQL SELECT distinct sum()
will not sum distinct values, so you need to first select the distinct values and then sum them up:
Select
SUM(Credits * Credit_Price) as "Cost", to_char(START_DATE, 'YYYY') as "YEAR",
PERSON_ID, ITEM_TYPE
[...]
from (select DISTINCT Credits , Credit_Price, START_DATE,PERSON_ID, ITEM_TYPE
[...])
WHERE
[...]
to_char(START_DATE, 'YYYY') = '2012'
or put the distinct inside the sum like this:
Select
SUM(DISTINCT Credits * Credit_Price) as "Cost", to_char(START_DATE, 'YYYY') as "YEAR",
PERSON_ID, ITEM_TYPE
[...]
WHERE
[...]
to_char(START_DATE, 'YYYY') = '2012'
Note that the 2 options aren't equel, do you want to sum the distinct Credits , Credit_Price or the distinct Credits * Credit_Price ?