我试图用英语和俄语显示数据
SELECT temp.*
FROM (SELECT DISTINCT CASE WHEN pd.LANGUAGE_ID = 'US' THEN COALESCE(TO_CHAR(pd.TRANSLATED_NAME), ' ')
END AS PRODUCT_NAME_US,
CASE WHEN pd.LANGUAGE_ID = 'US' THEN CONCAT(SUBSTR(pd.TRANSLATED_DESCRIPTION, 1, 30), '...')
END AS PRODUCT_DESC_US,
CASE WHEN pd.LANGUAGE_ID = 'RU' THEN COALESCE(TO_CHAR(pd.TRANSLATED_NAME), ' ')
END AS PRODUCT_NAME_RU,
CASE WHEN pd.LANGUAGE_ID = 'RU' THEN CONCAT(SUBSTR(pd.TRANSLATED_DESCRIPTION, 1, 30), '...')
END AS PRODUCT_DESC_RU,
CASE WHEN pin.WARRANTY_PERIOD = '00-00' THEN 'No Warranty'
WHEN EXTRACT(MONTH FROM pin.WARRANTY_PERIOD) = '00' THEN EXTRACT(YEAR FROM pin.WARRANTY_PERIOD) || ' years'
WHEN EXTRACT(YEAR FROM pin.WARRANTY_PERIOD) = '00' THEN EXTRACT(MONTH FROM pin.WARRANTY_PERIOD) || ' months'
WHEN EXTRACT(MONTH FROM pin.WARRANTY_PERIOD) <> '00' AND EXTRACT(YEAR FROM pin.WARRANTY_PERIOD) <> '00'
THEN EXTRACT(YEAR FROM pin.WARRANTY_PERIOD) || ' years and ' || EXTRACT(MONTH FROM pin.WARRANTY_PERIOD) ||' months'
ELSE 'No Warranty'
END AS "Warranty", inv.QUANTITY_ON_HAND AS IN_STOCK
FROM PRODUCT_DESCRIPTIONS pd JOIN PRODUCT_INFORMATION pin
ON pd.PRODUCT_ID = pin.PRODUCT_ID
JOIN INVENTORIES inv
ON inv.PRODUCT_ID = pin.PRODUCT_ID) temp
WHERE temp.PRODUCT_NAME_US LIKE '%Monitor%'
OR temp.PRODUCT_NAME_RU LIKE '%Монитор%'
AND temp.IN_STOCK < 1000
ORDER BY temp.PRODUCT_NAME_US ASC, temp."Warranty" DESC;
但结果包含空值。我该如何删除它们?
答案 0 :(得分:0)
尝试移动
在哪里temp.PRODUCT_NAME_US喜欢'%Monitor%' 或者temp.PRODUCT_NAME_RU喜欢'%Монитор%'
在内部查询内部并在外部查询中使用COALESCE