select a.MonthCode,b.STDskucode,a.skucode,c.sku_cn,
case when a,Channel='Omni KC' and a.SubChannel='NCA' then 'NCA' when a.Channel='Omni KC' and a.SubChannel<>'NCA' then 'NKC' else a.Channel end as DPChannel,
sum(a.GSV)/1000 as GSV,
0 as NIV
from DP_Forecast as a
inner join MD_STDSKU as b on b.stdskucode=a.stdskucode
inner join md_sku as c on a.skucode=c.skucode
group by select a.MonthCode,b.STDskucode,a.skucode,c.sku_cn,
case when a,Channel='Omni KC' and a.SubChannel='NCA' then 'NCA' when a.Channel='Omni KC' and a.SubChannel<>'NCA' then 'NKC' else a.Channel end
union all
select d.MonthCode,b.STDskucode,d.skucode,c.sku_cn,
case when d.DivisionDesc='Omni KC' and d.RegionDesc='NCA' then 'NCA' when d.DivisionDesc='Omni KC' and d.RegionDesc<>'NCA' then 'NKC' else d.DivisionDesc end as DPChannel ,
sum(d.GSV)/1000 as GSV,
sum(d.NIV)/1000 as NIV
from DW_PrimarySales as d
inner join MD_STDSKU as b on b.stdskucode=d.stdskucode
inner join md_sku as c on d.skucode=c.skucode
where d.MonthCode between '2023_M01' and '2023_M06'
group by d.MonthCode,b.STDskucode,d.skucode,c.sku_cn,
case when d.DivisionDesc='Omni KC' and d.RegionDesc='NCA' then 'NCA' when d.DivisionDesc='Omni KC' and d.RegionDesc<>'NCA' then 'NKC' else d.DivisionDesc end
报错信息如下
消息 4145,级别 15,状态 1,第 18 行
在应使用条件的上下文(在 ',' 附近)中指定了非布尔类型的表达式。
消息 4145,级别 15,状态 1,第 27 行
在应使用条件的上下文(在 ',' 附近)中指定了非布尔类型的表达式。
完成时间: 2023-07-30T18:13:56.2767725+08:00
```sql
```
加上点缩进啊
SELECT a.MonthCode, b.STDskucode, a.skucode, c.sku_cn,
CASE
WHEN a.Channel = 'Omni KC' AND a.SubChannel = 'NCA' THEN 'NCA'
WHEN a.Channel = 'Omni KC' AND a.SubChannel <> 'NCA' THEN 'NKC'
ELSE a.Channel
END AS DPChannel,
SUM(a.GSV)/1000 AS GSV,
0 AS NIV
FROM DP_Forecast AS a
INNER JOIN MD_STDSKU AS b ON b.stdskucode = a.stdskucode
INNER JOIN md_sku AS c ON a.skucode = c.skucode
GROUP BY a.MonthCode, b.STDskucode, a.skucode, c.sku_cn,
CASE
WHEN a.Channel = 'Omni KC' AND a.SubChannel = 'NCA' THEN 'NCA'
WHEN a.Channel = 'Omni KC' AND a.SubChannel <> 'NCA' THEN 'NKC'
ELSE a.Channel
END
UNION ALL
SELECT d.MonthCode, b.STDskucode, d.skucode, c.sku_cn,
CASE
WHEN d.DivisionDesc = 'Omni KC' AND d.RegionDesc = 'NCA' THEN 'NCA'
WHEN d.DivisionDesc = 'Omni KC' AND d.RegionDesc <> 'NCA' THEN 'NKC'
ELSE d.DivisionDesc
END AS DPChannel,
SUM(d.GSV)/1000 AS GSV,
SUM(d.NIV)/1000 AS NIV
FROM DW_PrimarySales AS d
INNER JOIN MD_STDSKU AS b ON b.stdskucode = d.stdskucode
INNER JOIN md_sku AS c ON d.skucode = c.skucode
WHERE d.MonthCode BETWEEN '2023_M01' AND '2023_M06'
GROUP BY d.MonthCode, b.STDskucode, d.skucode, c.sku_cn,
CASE
WHEN d.DivisionDesc = 'Omni KC' AND d.RegionDesc = 'NCA' THEN 'NCA'
WHEN d.DivisionDesc = 'Omni KC' AND d.RegionDesc <> 'NCA' THEN 'NKC'
ELSE d.DivisionDesc
END;