H2 DB - Column must be in Group By list

后端 未结 1 1531
滥情空心
滥情空心 2021-01-12 01:32

i am using H2-DB to access static databases...

i have a table which looks like:

COUNTRY     STATE       CITY         LAT     LNG     COUNTRYID      S         


        
相关标签:
1条回答
  • 2021-01-12 01:54

    MySQL is broken in regards to this. It allows columns in the GROUP BY that are neither in the group by nor arguments to aggregation functions. In fact, the documentation warns against using this extension.

    So you can do:

    SELECT state
    FROM DIYANET
    WHERE COUNTRY = 'Germany'
    GROUP BY STATE 
    ORDER BY STATE;
    

    Or something like this:

    SELECT state, min(city), min(lat), . . .
    FROM DIYANET
    WHERE COUNTRY = 'Germany'
    GROUP BY STATE 
    ORDER BY STATE;
    

    But SELECT * is not allowed and doesn't really make sense.

    0 讨论(0)
提交回复
热议问题