问下各位大佬,我现在写了一个sql的环比同比这2个字段但是得不到值,我是哪块没写对 SELECT city_code 城市, sum(case when left(week_start,7)='${month}' then average_transaction_price end) 当月商品住宅成交均价, sum(case when left(week_start,7)='${month}' then depolarization_cycle end) 当月库存去化周期, sum(case when left(week_start,4)=left('${month}',4) then average_transaction_price * number_of_transactions end) 当年月商品住宅成交额, sum(case when left(week_start,7)='${month}' then average_transaction_price * number_of_transactions end) 当月商品住宅成交额, sum(case when left(week_start,4)= CONVERT(varchar(4),DATEADD(year,-1,'${month}'+'-01'), 20) then average_transaction_price * number_of_transactions end) 去年商品住宅成交额, sum(case when left(week_start,7)= CONVERT(varchar(7),DATEADD(month,-1,'2021-01'+'-01'), 20) then average_transaction_price * number_of_transactions end) 上月商品住宅成交额 FROM [dbo].[t_volume_price_sales_information] where 1=1 ${if(city_code=='x00000',""," and city_code = '"+city_code+"'")} and enable = 1 and (left(week_start,7) = '2021-07 ') or (left(week_start,7) =CONVERT(varchar(7),DATEADD(month,-1,'2021-07'+'-01'), 20) ) and (left(week_start,4) = '2021 ') or (left(week_start,4) = CONVERT(varchar(4),DATEADD(year,-1,'2021-07'+'-01'), 20) ) group by city_code |