Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Come concatenare una stringa in SQL

SELECT  CASE WHEN COALESCE(b.totalCoupons, 0) > 3 THEN '(Important) '
            WHEN IsHighPriority = 1 THEN '(High Priority) '
            ELSE ''
        END + a.Name AS CompanyName
FROM    Company a
        LEFT JOIN
        (
            SELECT  Name, COUNT(*) totalCoupons
            FROM    Company
            GROUP   BY Name
        ) b ON a.name = b.name