question

watoth avatar image
watoth asked

Pivot question or Matrix

Im a mssql rookie but have an issue I have a table called draft DRAFT TABLE ---------- [draft_id] [int] IDENTITY(1,1) NOT NULL, [year] [numeric](18, 0) NULL, [round] [numeric](18, 0) NULL, [pick] [numeric](18, 0) NULL, [team_id] [int] NULL, [owner_id] [int] NULL, [manager_id] [int] NULL, [type] [varchar](50) NULL, [player_id] [int] NULL, I am wanting to create a query that will give me a matrix of sorts to view what team id has each pick rounds down the left and picks across the top. I have been looking at various examples but most are aggregate functions and I just dont seem to be able to put the pieces together. Any help would be appreciated. Thx, Bill
pivotcross-tab
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered
dynamic pivot is the way forward. Yes, you may not be doing a classic aggregate (SUM, COUNT), but if you've only got one row of data then what's the harm in using MAX or SUM? Sorry - not got the brainpower to write the query for you right now, but I'm sure someone will be along soon who's more awake / less full of lurgi.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.