Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: A SQL & PL/SQL practice question

Re: A SQL & PL/SQL practice question

From: Christof Müller <christof_mueller_at_t-online.de>
Date: Sat, 21 Jul 2001 21:23:32 GMT
Message-ID: <9hrrrp$vh9$06$1@news.t-online.com>

"Dino Hsu" <dino1_nospam_at_ms1.hinet.net> schrieb im Newsbeitrag news:nnp2ktomrsm0e1v9tfkskv1c9j2q1b4lhn_at_4ax.com...
> Dear all,
>
> A practice question is:
>
> Which line in the following select statement will produce an error?
>
> A.there are no errors in this statement
> B.from EMPLOYEE
> C.group by empid
> D.select dept,avg(salary)
>
> I chose D, but the answer is C.
>
> I know that select and group by don't match, but I have to choose one.
>
> Moreover, why do the choices of this kind of fine-SQL-error question
> come in random sequence? It can lead to confusion without making any
> good. I know there are many OCP out there, can you comment on this?
> Thanks in advance.
>
> Dino
>

Hi Dino,

referring to the possible answers the statement in your exam might look like

SELECT dept,avg(salary)
FROM employee
GROUP BY empid;

AVG is a group function. What kind of information might be groupable? The average salary of an empid? empid (-> Employee-ID) seems to be an unique value. You have to use dept in the GROUP BY clause to make this statement working. Therefore C wins.
Christof Received on Sat Jul 21 2001 - 16:23:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US