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
 count records by week of the day

Author  Topic 

Madhu_86
Starting Member

1 Post

Posted - 2011-07-29 : 06:48:00
Hello,

I Have following table in SQL.

Ticket_No Report_Date
1111 2011-06-20
2222 2011-06-20
3333 2011-06-21
4444 2011-06-21
5555 2011-06-21
6666 2011-06-22

What i want to do is query this table and find out the sql result as following...

Count Week_day
2 Monday
3 Tuesday
1 Wednesday

Madhu

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-07-29 : 06:58:36
[code]SELECT COUNT(*) as [Count], DATENAME(weekday,Report_Date) as [Week_day]
FROM YourTable
GROUP BY DATENAME(weekday,Report_Date)
[/code]
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-29 : 06:58:47
SELECT DATENAME(WEEKDAY, Report_Date), COUNT(*) FROM dbo.Table1
GROUP BY DATENAME(WEEKDAY, Report_Date)


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-29 : 06:59:08




N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -