KCL Software Solutions

Services with Multiple Sites, Sites with Multiple Services

To identity Services with multiple Site locations, use:
((SELECT COUNT(*) FROM dbo.GBL_BT_LOCATION_SERVICE WHERE SERVICE_NUM=bt.NUM)
    + CASE WHEN EXISTS(SELECT * FROM dbo.GBL_BT_OLS
        WHERE NUM=bt.NUM AND OLS_ID=2)
    THEN 1 ELSE 0 END) > 1

To identity Sites with multiple Services, use:

((SELECT COUNT(*) FROM dbo.GBL_BT_LOCATION_SERVICE WHERE LOCATION_NUM=bt.NUM)
    + CASE WHEN EXISTS(SELECT * FROM dbo.GBL_BT_OLS
        WHERE NUM=bt.NUM AND OLS_ID IN (3,4))
    THEN 1 ELSE 0 END) > 1

Did you find this article helpful?