ChuckKelly
ChuckKelly

Reputation: 1740

MySQL Distinct Active Users for the last month query

Alright I have tried alot and this looks just about right for me , but its def not:

SELECT COUNT( DISTINCT 'uid' ) AS `Records` , DATE( FROM_UNIXTIME( `epoch_timestamp` ) ) AS `Date`
FROM `log`
GROUP BY DATE( FROM_UNIXTIME( `epoch_timestamp` ) )
LIMIT 0 , 30

For w.e reason it returns a 1 next to each date. If I take out the distinct it appears to give a total records for that day count.

Upvotes: 0

Views: 55

Answers (1)

hofan41
hofan41

Reputation: 1468

Seems like your sql is incorrect, try replacing the single quotation marks around 'uid' with `.

SELECT COUNT( DISTINCT `uid` ) AS `Records` , DATE( FROM_UNIXTIME( `epoch_timestamp` ) ) AS `Date`
FROM `log`
GROUP BY DATE( FROM_UNIXTIME( `epoch_timestamp` ) )
LIMIT 0 , 30

Upvotes: 1

Related Questions