选择案例返回错误

时间:2018-01-02 11:46:48

标签: sql sql-server

如何从此脚本中获取“问题”或“确定”?

SELECT CASE
          WHEN COUNT (1) >0
             THEN 'problem'
          ELSE 'ok'
       END AS durum
     FROM (SELECT
    PBillingCode, OfferingSubTypeID
    INTO #Coklu_Basit_Sunu
    FROM 
        TOfferingBase
    GROUP BY 
        OfferingSubTypeID, PBillingCode
    ORDER BY PBillingCode

SELECT
    PBillingCode Faturalama_Kodu, 'Yandaki Faturalama Kodu Hem Çoklu Sunu Hem de Basit Sunuda Kullanılmıştır.' Açıklama
    FROM
        #Coklu_Basit_Sunu
    GROUP BY
        PBillingCode
    HAVING
    COUNT(PBillingCode) >=2

DROP TABLE #Coklu_Basit_Sunu)

1 个答案:

答案 0 :(得分:0)

我们真的可以说Programmish而不是英语或土耳其语,真是不是很棒吗?

SELECT CASE WHEN EXISTS (
    SELECT   PBillingCode
    FROM     TOfferingBase
    GROUP BY PBillingCode
    HAVING   Count(DISTINCT OfferingSubTypeID) > 1
) THEN 'problem' ELSE 'ok' END AS durum