Customers By Division

SELECT c.OrganisationV6 AS Company,
       d.div_name AS Division,
       c.contactV6 AS Contact,
       CASE
           WHEN c.stop_credit = 0 THEN 'Allow Credit'
           WHEN c.stop_credit = 1 THEN 'STOP CREDIT - DO NOT TRADE'
           WHEN c.stop_credit = 2 THEN 'STOP CREDIT - Refer to Accounts'
           ELSE 'Unknown'
       END AS [Allow/Stop Credit],
       P.PaytermName [Account Type],
       c.PostalAddress1 AS [Address 1],
       c.PostalAddress2 AS [Address 2],
       c.PostalAddress3 AS [City/Town],
       c.post_code AS [Postal Code],
       c.StreetState AS [State/Province],
       c.StreetCountry AS [Country]
FROM dbo.tblCust c
LEFT OUTER JOIN tblPayTermNames P ON c.Account_type = P.TermNo
LEFT OUTER JOIN tblDivlist D ON c.DefaultCustomerDivision = D.div_number
WHERE (DisabledCust = 'N')
ORDER BY DefaultCustomerDivision