Mech Mech - 4 months ago 7
SQL Question

SUM of COUNT(DISTINCT date)

I am having some difficulty with the following SQL:

SELECT SUM(mycount)
FROM
(SELECT COUNT(DISTINCT `User`) AS mycount
FROM `DBname`
WHERE date(Created) >= '2016-07-01'
) as R ;


The goal is to sum the count of unique entries over the course of the month.

Answer
SELECT SUM(mycount) 
FROM  (
    SELECT COUNT(DISTINCT `User`) AS mycount 
    FROM DBname 
    WHERE date(Created) >= '2016-07-01'
    GROUP BY date(Created)
) as R ; 
Comments