Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple counts on a single line, by day

Author  Topic 

bdatws
Starting Member

2 Posts

Posted - 2012-08-10 : 19:40:54
Newbie here.

Here's my base query:

SELECT day(`dateTime`) as day, `status`, count(*) FROM table WHERE `dateTime` >= '2012-XX-XX 00:00:00'
GROUP BY day, `status`

Output~

day status count(*)
1 sts1 194
1 sts2 367
1 sts3 72
2...
2..
2.

There are 3 possible statuses(statii?). The output of 3 lines is fine when looking at 1 day, but it can get kind of ugly when you have 30 days. I want the output to look like this but for the life of me I can't figure it out.

day status count(*) status count(*) status count(*)
1 sts1 194 sts2 367 sts3 72
2 sts1 201 sts2 376 sts3 91
3..
4.

I know this has got to be something simple. Please help

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-08-10 : 20:28:35
This looks like MySQL. If it is, there's a MySQL forum over at http://dbforums.com/. SQLTeam is a Microsoft SQL Server website.
Go to Top of Page

bdatws
Starting Member

2 Posts

Posted - 2012-08-10 : 20:53:58
Thanks. Off I go.
Go to Top of Page
   

- Advertisement -