🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.listserv.sqlinfo
Article #229

Re: Sub-query error

#229
From: Roland Zumkeller
Date: Mon, 07 Aug 2000 00:00
25 lines
1548 bytes
You cannot include a non-grouped field in a SELECT-claus when you dont
put it inside min(), max() etc. (i.e. aggregate functions).
The DBMS can't which ID it should take - there are several ones, since
it's grouped.

Roland


Dan Matthews schrieb:
> 
> Hi.
> Could someone do me a favour and tell me what is wong with the query below.
> When I try and run it, it complains abou the ID field not being part of an
> aggregate function.
> 
> Select a.name as Team, b.total - a.penalty as TeamTotal
> from
> (select v.name as name ,v.penalty as penalty ,v.id as id from VF1Team as v)
> as a,
> (select v1.name as name , sum(r.points) AS total , v1.id as id from VF1Team
> as v1 ,TeamPicks as t ,Driver as d ,RaceResults as r where v1.id = t.teamid
> and t.driverid = d.id and d.id = r.driverid group by v1.name) as b
> where a.id = b.id
> order by TeamTotal
> DESC;
Technical Details
Message-ID: <398DE6CA.25F43548@web.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8mfr19$mi9$1@newsg2.svr.pol.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11355a,58664d195145cb11
X-Google-Attributes: gid11355a,public
X-Google-Thread: 1131db,58664d195145cb11
X-Google-Attributes: gid1131db,public
From: Roland Zumkeller <Roland.Zumkeller@web.de>
Subject: Re: Sub-query error
Date: 2000/08/07
Message-ID: <398DE6CA.25F43548@web.de>
X-Deja-AN: 655207079
Content-Transfer-Encoding: 7bit
References: <8mfr19$mi9$1@newsg2.svr.pol.co.uk>
X-Accept-Language: de
Content-Type: text/plain; charset=us-ascii
X-Trace: fu-berlin.de 965601000 7135680 62.54.4.184 (16 [43476])
Mime-Version: 1.0
Newsgroups: bit.listserv.sqlinfo,mailing.database.sql-general