Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

missing expression error in the pivot query

Sid_ Z.Mar 25 2022

Hi

Version - oracle 19c
I am running the following pivot query. When I am passing dates in the FOR clause query is giving me result but when it passed as subquery it is giving me the error:

sample data:
test_sid table
sales_item buyer sales_item_name mnth qty
100001 57288 KEY HEXAGON 4MM SSH L48 ZN 01-JAN-22 400
100001 57288 KEY HEXAGON 4MM SSH L48 ZN 01-FEB-22 228.57
100001 57288 KEY HEXAGON 4MM SSH L48 ZN 01-MAR-22 371.43
100001 57288 01-APR-22 0
100001 57288 01-MAY-22 0
100001 57288 01-JUN-22 0
Query:
select * from
(
select sales_item, buyer, sales_item_name, mnth, qty
from test_sid
)
pivot
( sum(qty)
for mnth in ('01-JAN-2022','01-FEB-2022','01-MAR-2022','01-APR-2022','01-MAY-2022')
-- for mnth in (select distinct mnth from test_sid order by 1)

)
;

error - ORA-00936: missing expression
00936. 00000 - "missing expression"

Regards,
Sid
Sid

This post has been answered by Frank Kulash on Mar 25 2022
Jump to Answer
Comments
Post Details
Added on Mar 25 2022
10 comments
2,593 views