Code Inspection: Column should be in group by clause
Configure inspections: Settings | Editor | Inspections
Show intention actions: AltEnter
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;
Place the caret at the highlighted line and press AltEnter or click
.
Click the arrow next to the inspection you want to suppress and select the necessary suppress action.