'Deduplicated tables SQL query to obtain the unique value

I use SQL to query my database like this

SELECT DISTINCT A, 
                B,
                SUM(C) AS C
FROM TABLE
WHERE A = 2 AND DATE  >= 'xxxxx' AND DATE <= 'xxxxx'
GROUP BY 1,2;

I obtain this result :

A B C
2 0 32
2 1 32
2 2 32
2 3 32

How can i modify my query to obtain the unique row for the value 2 of column A ? Because i've some redundance in this table and i want the information agregated at the column A level and so i would like the result with only column A and C :

A C
2 32

Thanks in advance for your help,

sql


Solution 1:[1]

Answer by @David Lukas

select distinct 
    A, 
    C 
from (
    SELECT 
        A,
        SUM(C) AS C
    FROM TABLE 
    WHERE A = 2 
    AND DATE  BETWEEN 'xxxxx' AND <= 'xxxxx' 
    GROUP BY 1,2);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcio Rocha