当前时间为第一季度取 Q1这一列的CA,第二季度取Q2这一列的CA,第三季度取Q3这一列的CA,第四季度取Q4这一列的CA ,然后再进行计算,也就是说每个季度取不同的列来计算,如何取值,pgsql1楼:select if(quarter(now())=1,q1, if(quarter(now())=2,q2, if(quarter(now())=3,q3, if(quarter(now())=4,q4,''))) ) numberfrom tablewhere 类型='ca'PG似乎没有IF语句,我在MYSQL试了下可以——————————————————————————————————二楼:SELECT 类型, (CASE WHEN EXTRACT(quarter FROM now()::timestamp) = 1 THEN q1 WHEN EXTRACT(quarter FROM now()::timestamp) = 2 THEN q2 WHEN EXTRACT(quarter FROM now()::timestamp) = 3 THEN q3 ELSE q4 END) NUMBERFROM tableWHERE 类型='ca'函数稍有改动,习惯这样case when一直想着用变量了,没想到这样取数…采纳第一个评论的咯感谢