Home » SQL & PL/SQL » SQL & PL/SQL » ORA 0933: SQL command not properly ended
ORA 0933: SQL command not properly ended [message #9293] Fri, 31 October 2003 15:28 Go to next message
Caiàn
Messages: 2
Registered: October 2003
Junior Member
Hi

I need to use this query in oracle:

SELECT C_C AS A_CER, Sum(-1*(TOT-2)*Q) AS D_CA,
Sum((TOT-1)*Q) AS E_SC,
(SELECT SUM(Q) FROM pippo.pluto
WHERE COD_LOGIN=4 AND TOT=1 AND State LIKE '-%' AND
C_C=Principale.C_C) AS MAGAZZINO
FROM pippo.pluto as Principale
WHERE TOT<>0 AND COD_LOGIN=4
GROUP BY Principale.C_C;

but it doesn't run. There is this message:
Failure: ORA 0933: SQL command not properly ended

where is my mistake?
Thanks for your help
...and excuse me for my poor english :

Caian
Re: ORA 0933: SQL command not properly ended [message #9294 is a reply to message #9293] Fri, 31 October 2003 16:01 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Remove AS from the line referencing the Pluto table. The AS keyword only applies to aliases of columns, not tables.

FROM pippo.pluto  Principale
Re: ORA 0979: not a GROUP BY expression [message #9295 is a reply to message #9294] Sat, 01 November 2003 02:54 Go to previous messageGo to next message
Caiàn
Messages: 2
Registered: October 2003
Junior Member
I've tried with:
FROM pippo.pluto Principale
but it dosn't work.
the error is:
ORA 0979: not a GROUP BY expression
Why?
thanks
Re: ORA 0979: not a GROUP BY expression [message #9326 is a reply to message #9295] Tue, 04 November 2003 17:24 Go to previous message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
> but it dosn't work.

Sounds like it did work. The code has more than one error however.

Each item in the SELECT list must be either an aggregate expression e.g. SUM(x), AVG(x), COUNT(z), or else it must also appear in the GROUP BY list. For example,

SELECT x, y, SUM(z)
FROM some_tables
GROUP BY x, y;

is OK.

The following would give the "not a GROUP BY expression" error referring to Y, due to Y being in the SELECT list but not the GROUP BY list:

SELECT x, y, SUM(z)
FROM some_tables
GROUP BY x;
Previous Topic: Spool Problem
Next Topic: Call form6i from Report
Goto Forum:
  


Current Time: Fri Apr 26 18:58:40 CDT 2024