举个栗子,我有一个表金额表,t_money 我需要拿到1年内最高的金额,则SQL: select max(money) from t_money where 最近一年;同时,我需要拿到最近一个季度最高的金额 select max(money) from t_money where 最近一季度;
这样子写实在很粗暴,查两次表,如果多个条件,要各种写sql.一点都不优雅。如何只查一次表完成这个效果
收起
select max(money) 最近一年最大, max(case when 最近一月 then money end ) 最近一月最大 from t_money where 最近一年
报告相同问题?