最简单的办法直接硬算就行了,一年就那么4个季度,每个季度的最后一个月是固定的
比如 2023年2季度,它对应的最后一个月是2023-06-01至2023-06-30。只是变一下年就行了!
if($jd=2,CONCATENATE($year_code,"-06-01至",$year_code,"-06-30"),if($jd=1,CONCATENATE($year_code,"-03-01至",$year_code,"-03-31"),if($jd=3,CONCATENATE($year_code,"-09-01至",$year_code,"-09-30"),CONCATENATE($year_code,"-12-01至",$year_code,"-12-31"))))
where 1=1
and 时间字段>='${if(jd=2,CONCATENATE(year_code,"-06-01"),if(jd=1,CONCATENATE(year_code,"-03-01"),if(jd=3,CONCATENATE(year_code,"-09-01"),CONCATENATE(year_code,"-12-01"))))}'
and 时间字段<='${if(jd=2,CONCATENATE(year_code,"-06-30"),if(jd=1,CONCATENATE(year_code,"-03-31"),if(jd=3,CONCATENATE(year_code,"-09-30"),CONCATENATE(year_code,"-12-31"))))}'