SELECT ZYEAR,ZMONTH,ZZCPXLT,SUM(VVD02) VVD02 FROM( SELECT a.ZYEAR, a.ZMONTH, a.KAUFN, a.KDPOS, a.MATNR, a.AUART, a.VVD02, c.ZZCPXLT FROM dwm_dws_cbsjbz a left JOIN ( SELECT VBELN, POSNR, ZZCPXLT FROM dwm_sap_zsdt066 WHERE VBELN IN ( SELECT KAUFN FROM dwm_dws_cbsjbz WHERE AUART = 'OR1' AND ZYEAR = '2023' AND ZMONTH = '04' ) ) c ON a.KAUFN = c.VBELN AND a.KDPOS = c.POSNR WHERE a.AUART = 'OR1' AND a.ZYEAR = '2023' AND a.ZMONTH = '04' ) AS SFDF GROUP BY ZYEAR,ZMONTH,ZZCPXLT 为关键字ZZCPXLT 是NULL的赋值为无系列
时间: 2024-03-21 15:41:42 浏览: 132
您可以使用如下SQL语句将关键字ZZCPXLT是NULL的赋值为“无系列”:
```
SELECT
ZYEAR,
ZMONTH,
NVL(ZZCPXLT,'无系列') AS ZZCPXLT,
SUM(VVD02) VVD02
FROM(
SELECT
a.ZYEAR,
a.ZMONTH,
a.KAUFN,
a.KDPOS,
a.MATNR,
a.AUART,
a.VVD02,
c.ZZCPXLT
FROM
dwm_dws_cbsjbz a
LEFT JOIN (
SELECT VBELN, POSNR, ZZCPXLT
FROM dwm_sap_zsdt066
WHERE VBELN IN (
SELECT KAUFN
FROM dwm_dws_cbsjbz
WHERE AUART = 'OR1'
AND ZYEAR = '2023'
AND ZMONTH = '04'
)
) c ON a.KAUFN = c.VBELN AND a.KDPOS = c.POSNR
WHERE
a.AUART = 'OR1'
AND a.ZYEAR = '2023'
AND a.ZMONTH = '04'
) AS SFDF
GROUP BY ZYEAR, ZMONTH, ZZCPXLT;
```
在查询结果中,关键字ZZCPXLT为NULL的记录将会被替换为“无系列”并显示出来。
阅读全文