Query with grouping columns but no aggregate ignores column aliases
See original GitHub issueIf a query has grouping columns but no aggregates the aliases are ignored. To reproduce start the quick start batch and run the following query:
select AtBatting as foo, baseOnBalls as bar from baseballStats
group by AtBatting, baseOnBalls
limit 10
Result uses AtBatting
and baseOnBalls
instead of foo
, bar
If an aggregate is added then the aliases are correct:
select AtBatting as foo, baseOnBalls as bar , count(*) from baseballStats
group by AtBatting, baseOnBalls
limit 10
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top Results From Across the Web
7 Common GROUP BY Errors - LearnSQL.com
1. Forgetting GROUP BY with Aggregate Functions ... You use SELECT statements with the GROUP BY clause when you want to group and...
Read more >Using GROUP BY and JOIN-ing non-aggregated columns to ...
Maybe by aggregating the extra columns? SELECT foo, bar, baz, moo , MAX(ins_date) AS mdate ... Or join to the grouped fields and...
Read more >Selecting Ungrouped Columns Without Aggregate Functions
We'll call columns/expressions that are in SELECT without being in an aggregate function, nor in GROUP BY , barecolumns. In other words, if...
Read more >Aggregating and Grouping Data
COUNT and GROUP BY ... Aggregation allows us to combine results by grouping records based on value. It is also useful for calculating...
Read more >B.3.4.4 Problems with Column Aliases
Standard SQL disallows references to column aliases in a WHERE clause. This restriction is imposed because when the WHERE clause is evaluated, the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
working on it
Fixed by #7678