PostgreSQL里查询本周数据汇总 原SQL: 1 2 3 4 5 6 SELECT SUM(amount) AS all_amount FROM amount_table WHERE date_part('week', now()) = date_part('week', create_date) AND date_part('year', now()) = date_part('year', create_date) 优化后 1 2 3 4 5 SELECT SUM(amount) AS all_amount FROM amount_table WHERE create_date>=date_trunc('week', now()) 先计算开始