Forum Stats

  • 3,853,650 Users
  • 2,264,249 Discussions
  • 7,905,426 Comments

Discussions

Pivot SQL with dates

a74d0e45-ba66-4c44-a33a-910cab097cc0
edited Feb 25, 2015 5:13AM in SQL & PL/SQL

Hello,

I have the following query:

select *

    from

    (select pre_sap_cod

     from pre

    )

    pivot

    (

            count(pre_sap_cod)

            for pre_sap_cod in ('1' , '3')

    );

This is working fine,I get what I want:

   '1'     |      '3'

8708   |   281259

But there are more values that 1  and  3, and if I try to do this;

select *

    from

    (select pre_sap_cod

     from pre

    )

    pivot

    (

            count(pre_sap_cod)

            for pre_sap_cod in (select distinct pre_sap_cod from  pre)

    );

I get the error message:  ORA-00936: missing expression

What I can do?.   I am using Pivot because I want the information in columns.

Thanks in advance.

Tagged:

Answers

This discussion has been closed.