SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple counts on a single line, by day
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bdatws
Starting Member

2 Posts

Posted - 08/10/2012 :  19:40:54  Show Profile  Reply with Quote
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

USA
15557 Posts

Posted - 08/10/2012 :  20:28:35  Show Profile  Visit robvolk's Homepage  Reply with Quote
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 - 08/10/2012 :  20:53:58  Show Profile  Reply with Quote
Thanks. Off I go.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000