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
 get a count for a field for each week

Author  Topic 

gbeford
Starting Member

9 Posts

Posted - 2009-04-14 : 15:57:51
I have to create a stored procedure where it does a count on the CallAttened field for each week. I am not sure how to do this. I am really new to SQl can someone show me how to do this.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-04-14 : 16:01:56
Well..can you provide the table structure and some sample data...Is there some kind of date field that will help us find out the duration ?

You may need to use something like this..

select count(callattended) from <urtable> where dat_col > <fromdate> and date_col < <todate>
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-15 : 13:26:27
something like

SELECT Count(CallAttended), DATEADD(wk,DATEDIFF(wk,0,CallCreatedDate),0)
FROM Yourtable
GROUP BY DATEADD(wk,DATEDIFF(wk,0,CallCreatedDate),0)
Go to Top of Page
   

- Advertisement -