Re: Another Newbie SQL question....
From: Jim Lyons <godzilla_at_seuss.cc.utexas.edu>
Date: 1995/11/06
Message-ID: <1995Nov6.100748_at_seuss.cc.utexas.edu>#1/1
Date: 1995/11/06
Message-ID: <1995Nov6.100748_at_seuss.cc.utexas.edu>#1/1
In article <47h6kt$a1a_at_gondor.sdsu.edu>, Al Corvino <corvino_at_rohan.sdsu.edu> writes:
|> Ok, how can I select an avg(BAR) grouped by DEPT for each ID#? What I want to do is
|> something like:
|>
|> SELECT id# as ID_NUMBER, avg(BAR) FROM foo
|> group by DEPT;
|>
|> But this does not work. Any guesses as to what does?
Every version of SQL I have seen requires that the variables used in the GROUP BY clause appear in the SELECT clause. So, you would have to include DEPT in the select clause. You would probably want to add ID# to the GROUP BY clause as well.
-- Jim Lyons | Operating Systems Specialist Computation Center | 512-475-9331 University of Texas at Austin | godzilla_at_seuss.cc.utexas.edu http://www.cc.utexas.edu/~godzilla/jimlyons.htmlReceived on Mon Nov 06 1995 - 00:00:00 CET