sql的一些执行顺序

1、

select date_trunc('month',inserttime),count(1) from tablea group by inserttime;

先按inserttime分组后,再去格式化inserttime

select date_trunc('month',inserttime),count(1) from tablea group by date_trunc('month',inserttime);

按格式化之后的inserttime分组,再去格式化inserttime

 

2、

where在group by之前

posted @ 2025-05-21 10:11  hushuer  阅读(11)  评论(0)    收藏  举报