我有以下需要调整的基本查询:
SELECT PRODUCT_KEY,
PRODUCT_DESCRIPTION,
USC_CODE,
USC_DESCRIPTION
FROM ADMIN.PRODUCT_DIM
WHERE COUNTRY_CODE = 'US'
AND usc_code IS NOT NULL
GROUP BY PRODUCT_KEY,
PRODUCT_DESCRIPTION,
USC_CODE,
USC_DESCRIPTION
ORDER BY PRODUCT_KEY
仅当select
中有1个或没有product_keys时,我需要列出任何usc_code
字段。
因此,如果usc 12345只有0或1个产品,我希望看到usc,product,desc等。
所以我认为我需要在中间某处选择另一个选择,但不确定在哪里。
以下是一些示例数据:
PRODUCT_KEY PRODUCT_DESCRIPTION USC_CODE USC_DESCRIPTION
1000376001 B COMPLEX/C 76222 B-COMPLEX,W/C,ORAL
1000610001 OXYMETAZOLINE HCL 14200 DECONGESTANTS ALONE
1000611001 OXYMETAZOLINE HCL 14200 DECONGESTANTS ALONE
1000612001 OXYMETAZOLINE HCL 14200 DECONGESTANTS ALONE
1000613001 OXYMETAZOLINE HCL 14200 DECONGESTANTS ALONE
1000614001 OXYMETAZOLINE HCL 14200 DECONGESTANTS ALONE
1000615001 OXYMETAZOLINE HCL 78120 CRUDE/BULK MED
答案 0 :(得分:0)
SELECT PRODUCT_KEY, PRODUCT_DESCRIPTION, USC_CODE, USC_DESCRIPTION, COUNT(*)
FROM ADMIN.PRODUCT_DIM
WHERE COUNTRY_CODE = 'US'
AND usc_code is not null
GROUP BY PRODUCT_KEY, PRODUCT_DESCRIPTION, USC_CODE, USC_DESCRIPTION
HAVING COUNT(*) = 0 OR COUNT(*) = 1
ORDER BY PRODUCT_KEY
答案 1 :(得分:0)
试试这个
@Styles.Render("~/Content/my-Stylesheet.css")