在分组中使用列名或者列号,但不要混合使用
-- Good
select user_id, count(*) as total_charges
from charges
group by user_id
-- Good
select user_id, count(*) as total_charges
from charges
group by 1
-- Bad
select
timestamp_trunc(created_at, month) as signup_month,
vertical,
count(*) as users_count
from users
group by 1, vertical