Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 SQL Query Help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

224 Posts

Posted - 05/08/2013 :  22:43:06  Show Profile  Reply with Quote
Here is the sample data that i have

Name FILE Weekday COUNT
Shelb Receive 5/6/2013 Monday 104
Feli Receive 4/21/2013 Sunday 11
Shelb Send 4/23/2013 Tuesday 2
Jan Receive 4/27/2013 Saturday 12
Tris Send 5/4/2013 Saturday 3
Iri Receive 5/5/2013 Sunday 11
Shelb Receive 5/5/2013 Sunday 11
Lis Receive 4/25/2013 Thursday 92
Lar Send 5/2/2013 Thursday 122
Tony Receive 4/22/2013 Monday 134
Gracd Receive 5/5/2013 Sunday 6
Janet Receive 4/25/2013 Thursday 114
Franda Receive 4/24/2013 Wednesday 153
Johb Send 4/26/2013 Friday 25
Norc Receive 4/30/2013 Tuesday 144

I want end result would be like this

IRISP,SEND,count,count, count, count, count, count, count,
IRISP,RECEIVED,count,count, count, count, count, count, count,

All Users.....
I want to group by NAME,FILE,AND DATE, I want to create a report where i can compare all users Send and Receive Count. The data is only
two weeks. Weekday would be like this "date+weekday" and Count is already Counted How many he/she receive and Send per day/date.
Any help would be Great appreciate.

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 05/09/2013 :  00:47:26  Show Profile  Reply with Quote

SELECT Name,File,
STUFF(Weekday,1,CHARINDEX(' ',Weekday),'') AS Weekday,
FROM Table
GROUP BY Name,File
PIVOT (SUM([COUNT]) FOR WeekDay IN ([Monday],[Tuesday],[Wednesday],[THURSDAY],[FRIDAY],[SATURDAY],[SUNDAY]))p

SQL Server MVP

Edited by - visakh16 on 05/09/2013 00:47:44
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000