查询结果显示6个月份数据(1-6)(7-12),当前时间下如果查不到数据则显示上个期间数据,例如我传时间2024-5,显示的应该是2024年1-6月数据,如果没有这个区间数据则取2023年7月-12月的数据,SQL如下,怎么调整呐:WITH RESULT AS(SELECT GSMC,GSDM,SUM(CASE WHEN LEFT(NY,4)='${year}' THEN TO NUMBER(DOYZ) END) YZP ,SUM (CASE WHEN LEFT(NY,4) = 'Ş{year-1}' THEN TO NUMBER(DQYZ) END ) YZL ,SUM(CASE WHEN LEFT(NY,4)='Ş{year-2}' THEN TO NUMBER(DQYZ) END ) YZQ FROM Z CD HOZHUOYUE.DM FINE ASSET VALUES NOT USING SAP WHERE LEFT(NY,4) IN ('Ş{year}','${year-1}','${year-2}')AND RIGHT (NY,2)='${month end}'GROUP BY GSMC,GSDMUNION ALLSELECT'公司整体'GSMC,'1000' GSDM,SUM(CASE WHEN LEFT(NY,4)= '${year}' THEN TO NUMBER(DQYZ) END ) YZP ,SUM(CASE WHEN LEFT(NY,4)='${year-1)' THEN TO NUMBER(DQYZ) END ) YZL ,SUM(CASE WHEN LEFT(NY,4)='Ş{year-2}' THEN TO_NUMBER(DQYZ) END) YZQ FROM Z CD HOZHUOYUE.DM FINE ASSET VALUES NOT USING SAPWHERE LEFT(NY,4) IN ('Ş{year}','Ş{year-1}','${year-2}')AND RIGHT(NY,2) = '${month end}'SELECT R.*,CASE WHEN YZL = 0 OR YZL IS NULL OR YZP IS NULL THEN 0 ELSE YZP/YZL-1 END TBFROM RESULT RORDER BY CASE WHEN GSMC=THEN 9999999999999