Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 22nd, 2008, 7:55 PM   #1
Robocop
Programmer
 
Join Date: Sep 2004
Posts: 47
Rep Power: 0 Robocop is on a distinguished road
MSSQL - Help with query performance

I have a status column in a table with about 20 different status.
This table also has a date column.

I want to get the totals for each status and date as separate fields.

The only way I know to do this is creating temporary tables for each status (containing the date, status, and count) and relating them all by the date in a final query and grouping by the date and status.

I'm looking for help here on how to do this in a more effective way, because all these temporary tables are slowing down my query alot.

Thanks
Robocop is offline   Reply With Quote
Old May 26th, 2008, 3:48 PM   #2
Arla
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 208
Rep Power: 4 Arla is on a distinguished road
Re: MSSQL - Help with query performance

Um, wait, you have a table, with a status column, and a date column, and you want the total of each status for each date?

If that's it (and I'm not messing this up) then it's a piece of cake

select status, date, count(*)
from table_name
group by status, date
;

Done

If I've missed your question entirely, please respond with an example of what you are looking for.
Arla is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL injection on an insert query. TCStyle Other Web Development Languages 2 Nov 5th, 2006 7:14 PM
Slow Performance Counter coder0xff C++ 2 May 31st, 2006 9:29 PM
Process Id to Performance Counter Name coder0xff C++ 1 May 29th, 2006 11:19 AM
C# VS 2005 - SQL Query Parameters to an ODBC DataSource jcrcarmo C# 3 Apr 10th, 2006 3:58 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:41 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC