I am a .net developer that doesn't do a lot of SQL other than basic CRUD.
I have a table in SQL Server 2005:
CREATE TABLE [dbo].[Cases](
[CasesID] [int] IDENTITY(1,1) NOT NULL,
[Enterprise_Date_Key] [int] NOT NULL,
[Interval_Num] [int] NOT NULL,
[QueueID] [int] NOT NULL,
[TotalCases] [int] NOT NULL,
With data similar to:
4609 3 0 12455 4532
4610 3 0 12452 7963
4625 3 1 12455 4542
4626 3 1 12452 7993
4627 3 2 12455 4552
4628 3 2 12452 7823
.
And I run the query:
set @enterpriseDateKey = 3
select QueueID, interval_num, max(TotalCases)
from Case_Process_Status_Hourly_Fact a
where a.Enterprise_Date_Key = @enterpriseDateKey
group by QueueID,Interval_Num
The results are:
12452 0 4532
12455 0 7963
12452 1 4542
12455 1 7993
12452 2 4552
12455 3 7823
.
.
.
I need help with a query that will group the data differently where the Intervals are the columns (X axis) and the QueueID
are grouped on the rows (Y axis). Such as:
12452 4532 4542 4552 . .
12455 7963 7993 7823 . .
I will be honest, I don't know which direction to go to get the desired results. I don't know if I should go down the path of creating multiple subqueries to get my data or if there is any way to group differently to get my desired results. Any advice would be extremely helpful.