Home > Enterprise >  I want to query the row values as Column in SQL
I want to query the row values as Column in SQL

Time:05-17

I have a query to result in the below data from DB

enter image description here

But actually, I want to get the data as

enter image description here

Is there any way we can do this the SSRS? How can I do this? really stuck

CodePudding user response:

You can do this easily in SSRS without changing your dataset.

  1. Add a Matrix control to your report
  2. Drag the Assignee field to the Rows placeholder
  3. Drag the Priority_n field to the Columns placeholder
  4. Drag the Count_C field to the Data placeholder

that's it. If this does not help, let me know and I will update with sample images.

CodePudding user response:

Please recheck the column names;

SELECT * FROM (
  SELECT
    [Assignee],
    [Priority_n],
    [Count_C]
  FROM dataset
) Results
PIVOT (
  SUM([Count_C])
  FOR [Priority_n]
  IN (
    [High],
    [Medium],
    [Low]
  )
) AS PivotTable
  • Related