Subject RE: [ib-support] Group by problem...
Author Svend Meyland Nicolaisen
All fields which isn't selected using a aggregate function such as AVG needs
to be included in the GROUP BY clause, as you have done in the second query
example. What grouping do you expect?

-
SMN


-----Original Message-----
From: johanfredse [mailto:johanfredse@...]
Sent: 26. maj 2003 20:24
To: ib-support@yahoogroups.com
Subject: [ib-support] Group by problem...


Hi!

Why does the following GROUP BY give me an error? I'm using Firebird
RC1 on a XP.

SELECT DISTINCT SG_CURRENT.BLD_CODE,
SG_CURRENT.GRP_CODE,
SG_CURRENT.OBJ_CODE,
SG_CURRENT.OBJ_TYPE,
SG_CURRENT.BOX,
SG_CURRENT.MUX,
SG_CURRENT.ALARM_GRP,
AVG( SG_CURRENT.S01 ) AS SUM01,
AVG( SG_CURRENT.S02 ) AS SUM02,
AVG( SG_CURRENT.S03 ) AS SUM03,
AVG( SG_CURRENT.S04 ) AS SUM04,
AVG( SG_CURRENT.S05 ) AS SUM05,
AVG( SG_CURRENT.S06 ) AS SUM06,
AVG( SG_CURRENT.S07 ) AS SUM07,
AVG( SG_CURRENT.S08 ) AS SUM08,
AVG( SG_CURRENT.S09 ) AS SUM09,
AVG( SG_CURRENT.S10 ) AS SUM10,
AVG( SG_CURRENT.S11 ) AS SUM11,
AVG( SG_CURRENT.S12 ) AS SUM12,
AVG( SG_CURRENT.S13 ) AS SUM13,
AVG( SG_CURRENT.S14 ) AS SUM14,
AVG( SG_CURRENT.S15 ) AS SUM15,
AVG( SG_CURRENT.S16 ) AS SUM16,
AVG( SG_CURRENT.S17 ) AS SUM17,
AVG( SG_CURRENT.S18 ) AS SUM18,
AVG( SG_CURRENT.S19 ) AS SUM19,
AVG( SG_CURRENT.S20 ) AS SUM20,
AVG( SG_CURRENT.S21 ) AS SUM21,
AVG( SG_CURRENT.S22 ) AS SUM22,
AVG( SG_CURRENT.S23 ) AS SUM23,
AVG( SG_CURRENT.S24 ) AS SUM24
FROM SG_CURRENT
GROUP BY SG_CURRENT.OBJ_CODE
ORDER BY SG_CURRENT.GRP_CODE, SG_CURRENT.OBJ_CODE,
SG_CURRENT.OBJ_TYPE

but if i make it
GROUP BY SG_CURRENT.BLD_CODE, SG_CURRENT.GRP_CODE,
SG_CURRENT.OBJ_CODE, SG_CURRENT.OBJ_TYPE, SG_CURRENT.BOX,
SG_CURRENT.MUX, SG_CURRENT.ALARM_GRP
it will work but givs me wrong grouing!?

Thanks for any help!

Cheers
/Johan



To unsubscribe from this group, send an email to:
ib-support-unsubscribe@egroups.com



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/