Skip to content
Advertisement

NULL fields using PIVOT

I request your collaboration because pivot on a table and separating the records by null, but still leave the fields at 0 with NVL

Table

Código pivot

Result:

Expected result:

Optional

Advertisement

Answer

You need to put the column values in the pivot list:

Oracle Setup:

Query:

Output:

PRODUCT | SHIRTS | CAPS | STOCKS | GLASSES | SHOES
:------ | -----: | ---: | -----: | ------: | ----:
value   |   1200 |    0 |      0 |     100 |     0

db<>fiddle here

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