-5

I need help with the following output. Tried case, Distinct, Group By, failed. Join might help, but still couldn't write a query with join.

enter image description here

  • 1
    This is the exact same as your previous query here which was closed - and only asked 30 minutes previously. What makes you think you're going to get a different answer this time? Also, when asking questions, please provide your table structures as DDL and your data as DML. – Vérace May 31 at 12:11
  • I was typing answer however after seeing above comment, I stopped it. Please refer this link for answer --> sqlshack.com/multiple-options-to-transposing-rows-into-columns – Learning_DBAdmin May 31 at 12:12
  • At least show us what you have tried. Create a db-fiddle, and Im pretty sure someone can help – Lennart May 31 at 13:40
  • @Vérace Previously I mistakenly posted without the picture that has data. – Rony Hassan May 31 at 15:36
  • That's all the data Employee Salary table has. I will be trying pivot and cursor. Thanks @Learning_DBAdmin – Rony Hassan May 31 at 15:37
-2

Welcome on dba.stackexchange. Please be more specific in future request. But I still think I can extract the gist of your request:

Since too many questions concerning your request are unclear I just point you to this guide (myself not working on MS SQL): https://docs.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot?view=sql-server-ver15

This means you need to select the (the names in your axample), choose the aggregate function (sum of AMOUNTS) and in the FOR-clause choose the , i.e. the rubrics (column SALARY_HEAD).

Hope that helps to get you started Andreas

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.