You must be coming from MySQL. MySQL - IMHO misleadingly, incorrectly, and in a black-magicky, unpredictible sort of way - allows you to specify partial GROUP BY
queries and the database engine tries to figure out from the rest of the query which value of the non-grouped-by columns you want. Standard SQL (Firebird and most other RDBMSes), on the other hand, does not; it requires any non-aggregate columns to be contained in the group by, and any non-group-by columns to explicitly specify which row you want.
In your case, the offending columns are MEASUREMENT
, LL
, and UL
. You need to specify which MEASUREMENT
, LL
, and UL
you want (yes, even if they are all the same; the database engine has no way of knowing or guaranteeing this), or if you want to group by one or more of the columns or possibly you forgot to aggregate (Did you want the SUM
?)
Examples of valid queries:
Group by all columns (equivalent to a SELECT DISTINCT
):
SELECT TEST_DESC, MEASUREMENT, LL, UL
FROM T_TABLE2
GROUP BY TEST_DESC, MEASUREMENT, LL, UL
Group by MEASUREMENT
as well and return the MIN
LL and MAX
UL:
SELECT TEST_DESC, MEASUREMENT, MIN(LL), MAX(UL)
FROM T_TABLE2
GROUP BY TEST_DESC, MEASUREMENT
SUM
non-grouped columns:
SELECT TEST_DESC, SUM(MEASUREMENT), SUM(LL), SUM(UL)
FROM T_TABLE2
GROUP BY TEST_DESC
A combination of aggregates:
SELECT TEST_DESC, COUNT(DISTINCT MEASUREMENT), SUM(LL), MAX(UL)
FROM T_TABLE2
GROUP BY TEST_DESC
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…