Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Scripting Languages (http://www.programmingforums.org/forum39.html)
-   -   MSSQL - Help with query performance (http://www.programmingforums.org/showthread.php?t=15862)

Robocop May 22nd, 2008 8:55 PM

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

Arla May 26th, 2008 4:48 PM

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.


All times are GMT -5. The time now is 4:21 AM.

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