Subject Group by problem...
Author johanfredse
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