Skip to content
Advertisement

Compress the pivot table result to one row in SQL

I want to have a single line result in SQL pivot table like below

+------------+-----------+-----------+----------+
| Request_id | IT Review | SO Review | Approved |
+------------+-----------+-----------+----------+
|    11111   |    09-19  |   09-20   |   09-21  |
+------------+-----------+-----------+----------+

However, I can’t get rid of the null value in the columns:

+------------+-----------+-----------+----------+
| Request_id | IT Review | SO Review | Approved |
+------------+-----------+-----------+----------+
|   11111    |   09-19   |    NULL   |   NULL   |
|   11111    |    NULL   |   09-20   |   NULL   |
|   11111    |    NULL   |    NULL   |  09-21   |
+------------+-----------+-----------+----------+

Below is my query, could anyone please shed some lights on how to revise my query? Thanks!

Advertisement

Answer

Try replace

with

Something like that:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement