How to use GROUP BY in firebird

后端 未结 3 1064
天命终不由人
天命终不由人 2020-12-20 17:43

The structure of T_TABLE2 is

ID INT
TBL1_ID INT
TESTER VARCHAR
LOT_ID VARCHAR
GRP VARCHAR
SITE_NUM INT
TEST_NUM VARCHAR
TEST_DESC VARCHAR
ME         


        
3条回答
  •  再見小時候
    2020-12-20 18:03

    While some databases, such as MySQL, are more lenient, in standard SQL when you use GROUP BY, the SELECT list must only contain the columns being grouped by and aggregate functions (e.g. SUM(), MAX()). If you were allowed to specify other columns, it's unpredictable which of the rows of the grouped column these columns will come from -- you may even get a mix of columns from different rows.

    So you need to do something like:

    SELECT TEST_DESC, MAX(MEASUREMENT) MEASUREMENT, MAX(LL) LL, MAX(UL) UL 
    FROM T_TABLE2 
    GROUP BY TEST_DESC
    

提交回复
热议问题