Re: Newbie SQL Question

From: Archana Rajagopal <archana_at_tsp-inc.com>
Date: Mon, 29 Mar 1999 19:50:36 -0500
Message-ID: <7dp7em$8fr$1_at_news1.epix.net>


Hi Vic,
Check the syntax of GROUP BY clause...
All columns in SELECT clause must be used in the GROUP BY clause that are NOT part of the vector function.

Think about it... This is required as for a value of CUS_CODE in your example, if multiple values of CUS_BALANCE exist the GROUPING cannot be performed legally !!

This is the reason when you remove CUS_BALANCE from the SELECt aclause the QUERY works...

Try adding CUS_BALANCE to the GROUP BY clause... Semantically this may or may NOT be meaningful....

Hope this helps..

Archana R.

Vic Smyth wrote in message <37000FFE.1084_at_megsinet.net>...
>I'm doing a project for school using sqlplus (command-line sql for Oracle).
I
>keep getting the following error message when I try to do a GROUP BY. Other
>commands I have no problem with. If I take out CUSTOMER.CUS_BALANCE on line
1
>the command executes and I get everything except the column I deleted. My
>text and the help screen in Oracle are not much help. What am I doing
wrong?
>
>Thanks in advance!
>
>Vic
>
>To reply to email remove the "myth" from the address.
>
>SQL> SELECT CUSTOMER.CUS_CODE, CUSTOMER.CUS_BALANCE,
> 2 SUM(LINE.LINE_UNITS * LINE.LINE_PRICE)
> 3 FROM CUSTOMER, INVOICE, LINE
> 4 WHERE CUSTOMER.CUS_CODE = INVOICE.CUS_CODE
> 5 AND LINE.INV_NUMBER = INVOICE.INV_NUMBER
> 6 GROUP BY CUSTOMER.CUS_CODE;
>SELECT CUSTOMER.CUS_CODE, CUSTOMER.CUS_BALANCE,
> *
>ERROR at line 1:
>ORA-00979: not a GROUP BY expression
Received on Tue Mar 30 1999 - 02:50:36 CEST

Original text of this message