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.
Author |
Topic |
tugsy
Starting Member
10 Posts |
Posted - 2007-04-12 : 00:01:40
|
Hi, I have a query that gets the data for a specific week (starting Monday).The below statement returns the data for the whole week mon-friWhat I would like to do is to have the data come back in a table with columns Mon,Tue,Wed etc breaking down the data.How would I make the data come back by splitting it into columns mon,Subtot1,tue,Subtot1,wed,Subtot1,thur,Subtot1,fri,Subtot1SELECT dbo.People.FirstName, dbo.People.LastName, dbo.RequestTypes.Title, dbo.Companies.CompanyName, dbo.People.PersonId, dbo.Actions.RequestId, dbo.Actions.ActionDate, dbo.Actions.TimeUsed As Subtot1FROM dbo.Actions INNER JOIN dbo.Requests INNER JOIN dbo.Companies ON dbo.Requests.CompanyId = dbo.Companies.CompanyId ON dbo.Actions.RequestId = dbo.Requests.RequestId INNER JOIN dbo.RequestTypes ON dbo.RequestTypes.RequestTypeId = dbo.Actions.RequestTypeId INNER JOIN dbo.People ON dbo.People.PersonId = dbo.Actions.ActionedByIdWHERE (dbo.People.PersonId = 'JO' dbo.Actions.ActionDate > DATEADD(wk, DATEDIFF(wk,0,getdate()), 0) AND dbo.Actions.ActionDate < DATEADD(wk, DATEDIFF(wk,0,getdate()), 5) ) GROUP BY dbo.RequestTypes.Title, dbo.People.FirstName, dbo.People.LastName, dbo.Companies.CompanyName, dbo.People.PersonId, dbo.Actions.RequestId, dbo.Actions.ActionDate, dbo.Actions.TimeUsedThanks in advance,Tugsy |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-12 : 00:08:21
|
search for cross tab query in this forum. This is a commonly ask question. KH |
|
|
|
|
|
|
|