sql >> Base de Datos >  >> RDS >> Sqlserver

Cómo concatenar cadenas en 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