0

Hi i've the below query in oracle to get data. it is working fine in sql server, but, when i tried to execute this in oracle it is giving and error.

    SELECT PRODUCT, FRED, KATE FROM (
    SELECT CUST, PRODUCT, QTY
    FROM Product
    )
    PIVOT
    (
    SUM(QTY) FOR CUST IN (FRED, KATE)
    )
    ORDER BY Product

Error:

enter image description here

and the table o/p is as below

enter image description here

Thanks

1 Answer 1

2

Try SUM(QTY) FOR CUST IN ('FRED' as fred , 'KATE' as kate)

3
  • thanks buddy, this worked. if you don't mind could you please tell me what happened here. also could you please suggest me any site for learning PIVOT table.? thanks
    – Rakesh
    Dec 6, 2012 at 12:15
  • @Rakesh unquoted fred and kate you initially specified were treated as oracle identifiers, though pivot for clause required a list of cust values to be transposed into columns. Dec 6, 2012 at 12:18
  • @Rakesh I guess docs are pretty good: docs.oracle.com/cd/B28359_01/server.111/b28286/… Dec 6, 2012 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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