Scalar function COALESCE
- class928417
- Aug 12, 2014
- 1 min read
פונקציה סקלרית COALESCE למי שרוצה להציג מס' אפשרויות הצגה (ללא null) כאשר יש סיכוי שאחד השדות או יותר הוא Null.
להלן דוגמא :
use northwind
go
--- For each customer display the City, Region and fax numer in one column (שרשור)
-- if one or more of the expressions is null then dont display it. if all are null then
-- display "NO INFO"
-- example : customerid: ALFKI will display "Berlin 0.0-0076545"
select
customerid, CompanyName , city , region , fax
,COALESCE(city+' '+region+' '+fax ,city+' '+fax ,city+' '+region
,region+' '+fax ,city ,region ,fax, 'No info') as NewInfo
from Customers
Comentarios