DataGrip 2023.3 Help

Code Inspection: Column should be in group by clause

Reports columns that are not in the GROUP BY clause or inside an aggregate function call.

Example (Microsoft SQL Server):

CREATE TABLE t1 (a INT, b INT); SELECT a, b FROM t1 GROUP BY a;

If you run the SELECT query, you will receive an error because Microsoft SQL Server expects the b column in GROUP BY or used inside an aggregate function. The following two examples will fix the error.

SELECT a, b FROM t1 GROUP BY a, b; SELECT a, max(b) max_b FROM t1 GROUP BY a;

Suppress an inspection in the editor

  1. Place the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 13 May 2022