How can I get a sum but only of distinct records

MY query is

SELECT distinct affiliate_date,affiliate_orders_id,affiliate_value,affiliate_payment,affiliate_percent,typeofsale FROM affiliate_sales

now I want to get the sum of these records
so the sum of (affiliate_sales) only for the distinct records

how can I do this?

Please provide:

  • table descriptions as create statements
  • sample data as insert statements
  • expected output from the sample data you provide
SELECT SUM ( affiliate_value ) ,  . . . .
FROM
(
    SELECT distinct 
           affiliate_date,affiliate_orders_id,affiliate_value,affiliate_payment,affiliate_percent,typeofsale
    FROM   affiliate_sales 
) AS D