Home » SQL & PL/SQL » SQL & PL/SQL » PIVOT - SQL Command not properly ended (TOAD 10.6)
PIVOT - SQL Command not properly ended [message #609005] Thu, 27 February 2014 23:44 Go to next message
kupstar
Messages: 16
Registered: November 2013
Location: PNG
Junior Member
Hi experts,
Can someone make my following query work? I am running the query on Toad 10.6 and I am running into the error 'SQL Command not properly ended'. I am not sure what is wrong with my script.

SELECT *
FROM (SELECT employee#, paytype, sum(amt) amt FROM pehistpay GROUP BY employee#, paytype)
PIVOT (sum(amt) FOR paytype IN ('S','A','T','D','B'));

Thankyou in advance.
Kupstar
Re: PIVOT - SQL Command not properly ended [message #609006 is a reply to message #609005] Thu, 27 February 2014 23:51 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
the SELECT employee#... statement must be valid which it it NOT.
Re: PIVOT - SQL Command not properly ended [message #609009 is a reply to message #609006] Fri, 28 February 2014 00:14 Go to previous messageGo to next message
kupstar
Messages: 16
Registered: November 2013
Location: PNG
Junior Member
Blackswan, I ran the select statement which you meant but it ran OK with no errors. Would you be able to point out my invalid code in the query?
Re: PIVOT - SQL Command not properly ended [message #609015 is a reply to message #609009] Fri, 28 February 2014 00:47 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Use SQL*Plus and copy and paste your session.

Re: PIVOT - SQL Command not properly ended [message #609017 is a reply to message #609005] Fri, 28 February 2014 00:59 Go to previous messageGo to next message
_jum
Messages: 577
Registered: February 2008
Senior Member
May be in the TOAD editor the statement BEFORE the given is not properly ended ?
Try your statement in an empty worksheet or better as @Michel stated
Quote:
Use SQL*Plus and copy and paste your session.
Re: PIVOT - SQL Command not properly ended [message #609021 is a reply to message #609005] Fri, 28 February 2014 01:21 Go to previous messageGo to next message
kupstar
Messages: 16
Registered: November 2013
Location: PNG
Junior Member
I am still getting the same error when I tried same query in SQL plus.
Re: PIVOT - SQL Command not properly ended [message #609023 is a reply to message #609021] Fri, 28 February 2014 01:23 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Don't you know what COPY & PASTE mean?

Re: PIVOT - SQL Command not properly ended [message #609024 is a reply to message #609023] Fri, 28 February 2014 01:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Also post the result of "select * from v$version".

Re: PIVOT - SQL Command not properly ended [message #609025 is a reply to message #609024] Fri, 28 February 2014 01:32 Go to previous messageGo to next message
kupstar
Messages: 16
Registered: November 2013
Location: PNG
Junior Member

I did copy and paste but am getting the same error. Refer attached for details.
  • Attachment: error.JPG
    (Size: 82.53KB, Downloaded 613 times)
Re: PIVOT - SQL Command not properly ended [message #609026 is a reply to message #609025] Fri, 28 February 2014 01:34 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

PIVOT was introduced in 11g. There is a reason we ask you ALWAYS post your Oracle version.

Note this text, you don't need to post an image to copy and paste text.

Re: PIVOT - SQL Command not properly ended [message #609027 is a reply to message #609026] Fri, 28 February 2014 02:13 Go to previous messageGo to next message
kupstar
Messages: 16
Registered: November 2013
Location: PNG
Junior Member
Ok noted but how do I do a pivot for oracle 10G and prior versions?
Re: PIVOT - SQL Command not properly ended [message #609029 is a reply to message #609027] Fri, 28 February 2014 02:15 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Just search for PIVOT or "max(decode".

Re: PIVOT - SQL Command not properly ended [message #609030 is a reply to message #609029] Fri, 28 February 2014 02:26 Go to previous messageGo to next message
kupstar
Messages: 16
Registered: November 2013
Location: PNG
Junior Member
I dont understand when you say 'search for PIVOT' or "max(decode". Where do I search?
Re: PIVOT - SQL Command not properly ended [message #609031 is a reply to message #609030] Fri, 28 February 2014 02:53 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
On this forum using the search function at the top
Previous Topic: Open Cursor for with an Exception Clause
Next Topic: sql execution
Goto Forum:
  


Current Time: Thu Apr 25 16:40:52 CDT 2024