SQL Server query
Posted
by carrot_programmer_3
on Stack Overflow
See other posts from Stack Overflow
or by carrot_programmer_3
Published on 2010-05-18T14:37:19Z
Indexed on
2010/05/18
14:40 UTC
Read the original article
Hit count: 175
Hi,
I have a SQL Server DB containing a registrations table that I need to plot on a graph over time. The issue is that I need to break this down by where the user registered from (e.g. website, wap site, or a mobile application).
the resulting output data should look like this...
[date] [num_reg_website] [num_reg_wap_site] [num_reg_mobileapp]
1 FEB 2010,24,35,64
2 FEB 2010,23,85,48
3 FEB 2010,29,37,79
etc...
The source table is as follows...
UUID(int), signupdate(datetime), requestsource(varchar(50))
some smple data in this table looks like this...
1001,2010-02-2:00:12:12,'website'
1002,2010-02-2:00:10:17,'app'
1003,2010-02-3:00:14:19,'website'
1004,2010-02-4:00:16:18,'wap'
1005,2010-02-4:00:18:16,'website'
Running the following query returns one data column 'total registrations' for the website registrations but I'm not sure how to do this for multiple columns unfortunatly....
select CAST(FLOOR(CAST([signupdate]AS FLOAT ))AS DATETIME) as [signupdate], count(UUID) as 'total registrations' FROM [UserRegistrationRequests] WHERE requestsource = 'website'
group by CAST(FLOOR(CAST([signupdate]AS FLOAT ))AS DATETIME)
© Stack Overflow or respective owner