Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Any SQL gurus? Stuck on a query.

$
0
0

I'm trying to write a SQL View that's falling down because one of the fields is multi-select in the original application.

The original application is Sage CRM and I need to extract all active customers, with it's market segment and ordered by Salesman and territory.

Most of the view is simple but the Market segment is a multi select field that can contain nothing, one entry or multiple entries of the form 1001, 1002, 2004, 3013 etc.

If the field contains a single entry, not bounded by commas I can do it as follows:

SELECT "Users"."User_FirstName", "Users"."User_LastName", "Company"."Comp_Name", "Territories"."Terr_Caption", comp_market_segment

FROM "CRM"."dbo"."Users" "Users" INNER JOIN ("CRM"."dbo"."Territories" "Territories" INNER JOIN "CRM"."dbo"."Company" "Company"

ON "Territories"."Terr_TerritoryID"="Company"."Comp_SecTerr") ON...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>