How to Ersetzen Sie eine Zeichenfolge, wenn Datensatz ist NULL in T-SQL

Schreibe ich eine T-SQL-Bericht zeigt, dass die Anzahl der Konten, die in unterschiedlicher Status für unterschiedliche Kunden. Der Bericht ist das Ergebnis in etwa so aus:

Customer1    NoService        7
Customer1    IncompleteOrder  13
Customer1    NULL             9
Customer2    NoService        12
Customer2    Available        19
Customer2    NULL             3
...

Den "NULL" status-Daten gültig sind, aber anstelle der Anzeige NULL, ich will die Anzeige "Pending". Hier ist mein SQL so weit:

USE cdwCSP;
SELECT
   sr.sales_region_name   AS SalesRegion
   , micv.value
   , COUNT(sr.sales_region_name)
FROM prospect p
   LEFT JOIN sales_region sr
     ON p.salesRegionId = sr.sales_region_number
   LEFT JOIN prospectOrder po
     ON po.prospectId = p.prospectId
   LEFT JOIN wo
     ON wo.prospectId = p.prospectId
   LEFT JOIN woTray wot
     ON wot.woId = wo.woId
   LEFT JOIN miscInformationCustomerCategory micc
     ON micc.prospectId = p.prospectId
   LEFT JOIN miscInformationCustomerValues micv
     ON micv.miscInformationCustomerCategoryId = micc.miscInformationCustomerCategoryId
   LEFT JOIN miscInformationCategory mic
     ON micc.miscInformationCategoryId = mic.miscInformationCategoryId
WHERE wot.dateOut IS NULL
     AND mic.categoryName LIKE '%Serviceability%'
GROUP BY sr.sales_region_name, micv.value
ORDER BY sr.sales_region_name, micv.value;

Jede Hilfe würde geschätzt, ich bin immer noch lernen, T-SQL, so könnte dies eine einfache Frage zu beantworten.

InformationsquelleAutor dvanaria | 2011-04-01
Schreibe einen Kommentar