Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    58

    Unanswered: Help with Pivoting data!!!

    Hi Guys,

    I have this input.

    Code:
    15	Name 	 DefAct
    15	Expression 	 If Deault_Values
    15	SqlType 	3
    15	ParsedExpression 	SETID
    15	SourceColumn 	 Deault_Values.SETID;Deault_Values.GL_ACCOUNT
    15	Precision 	0
    15	ColScale 	0
    15	ExtendedPrecision 	0
    16	Name 	 DefPrd
    16	Expression 	 If Deault_Values.SETID='MYSIA'
    16	SqlType 	3
    16	ParsedExpression 	 if IsNull(Deault_Values.PSGL_PRODUCT_CODE) 
    16	SourceColumn 	 Deault_Values.SETID;Deault_Values
    16	Precision 	0
    16	ColScale 	0
    16	ExtendedPrecision 	0
    Following is the query, i am using to pivot the data.

    Code:
    SELECT [SUBPIVOT], [Name ], [Expression ], [SqlType ],[ParsedExpression ],[SourceColumn ],[Precision ],[ColScale ],[ExtendedPrecision ]
    FROM DL_TEST_PIVOT 
    PIVOT 
    ( 
        LAST(COLDATA)
        FOR [COLNAM] IN ([Name ], [Expression ], [SqlType ],[ParsedExpression ],[SourceColumn ],[Precision ],[ColScale ],[ExtendedPrecision ])
        ) as P
    It should work, but i am getting some error. Can somebody point out what i am doing wrong.

    Cheers!!!

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    "Some error" is difficult to fix. If you use Oracle, then you should have got ORA-XXXXX error code along with the message text. Which one is it?

    On the other hand, square brackets certainly don't look Oracle-ish. So - are you sure you use Oracle?

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Identifiers in SQL may not contain [ or ].

    If you created your table and columns using those square brackets, you need to enclose them in double quotes.
    e.g: "[Name ]" is a valid identifier in SQL, but [Name ] is not
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •