Re: Noob query

From: Doug Miller <doug_at_milmac_dot_com_at_example.com>
Date: Wed, 7 Jan 2015 22:12:31 +0000 (UTC)
Message-ID: <XnsA41BAF065DB94dougmilmaccom_at_213.239.209.88>


Bint <bint_at_ign.com> wrote in news:D0D30A0B.FAFF%bint_at_ign.com:

> Hello,
>
> I'm pretty new to mySQL. If I have a table with these fields:
>
> userid date action
>
> How would I form a query to count the number of records within the past hour
> with different userids? That is, I want to find out how many unique users
> are active in the past hour.
>
> I know how to count all the active records in the past hour:
> SELECY count(*) FROM records WHERE date >= DATE_SUB(NOW(),INTERVAL 1
HOUR)"
>
> But I want the number of unique user id's in that list.

SELECT COUNT (DISTINCT userid) ... Received on Wed Jan 07 2015 - 23:12:31 CET

Original text of this message