Select distinct users group by time range
how do i do the link above in google big query's version of SQL?
Update with details:
I have a table with the following info
 |day| user_id  
I want to calculate the number of distinct user_id's for a date:
- For that date
- For that week up to that date (Week to date)
- For the month up to that date (Month to date)
Example of input table:
 | day        | user_id    
 | 2013-01-01 | 1          
 | 2013-01-03 | 3          
 | 2013-01-06 | 4          
 | 2013-01-07 | 4          
Expected output:
 | day        | time_series | cnt        |                 
 | 2013-01-01 | D           | 1          |                 
 | 2013-01-01 | W           | 1          |                 
 | 2013-01-01 | M           | 1          |                 
 | 2013-01-03 | D           | 1          |                 
 | 2013-01-03 | W           | 2          |                 
 | 2013-01-03 | M           | 2          |                 
 | 2013-01-06 | D           | 1          |                 
 | 2013-01-06 | W           | 1          |                 
 | 2013-01-06 | M           | 3          |                 
 | 2013-01-07 | D           | 1          |                 
 | 2013-01-07 | W           | 1          |                 
 | 2013-01-07 | M           | 3          |
P.S. Similar question was ask for postgresql - but I need the version for BigQuery
 
    