Mech
Mech

Reputation: 4015

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.

Upvotes: 0

Views: 17939

Answers (1)

SIDU
SIDU

Reputation: 2278

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

Upvotes: 6

Related Questions