Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.67 KB | None | 0 0
  1. SELECT      DISTINCT
  2.         CLID,
  3.         CDID,
  4.         STUFF(( SELECT  '|' + SubTableDemographics.TextValue
  5.                 FROM    ( SELECT    CLID,
  6.                                     CDID,
  7.                                     TextValue
  8.                           FROM      ClCxDemographicNoneExclusiveValues
  9.                                     INNER JOIN CxDemographicsDefinedTextValues ON ClCxDemographicNoneExclusiveValues.CDDTVID = CxDemographicsDefinedTextValues.CDDTVID
  10.                           WHERE     CLID IN ( 4586, 4587, 4588, 4589, 4590,
  11.                                               4591, 4592, 4593, 10241, 10277,
  12.                                               10306, 10350, 10351, 10354,
  13.                                               10355, 10376, 10377, 10591,
  14.                                               10593 )
  15.                         ) SubTableDemographics
  16.                 WHERE   SubTableDemographics.CLID = TableDemographics.CLID
  17.                         AND SubTableDemographics.CDID = TableDemographics.CDID
  18.               FOR
  19.                 XML PATH('')
  20.               ), 1, 1, '') AS DemographicValue
  21. FROM    ( SELECT    CLID,
  22.                     CDID,
  23.                     TextValue
  24.           FROM      ClCxDemographicNoneExclusiveValues
  25.                     INNER JOIN CxDemographicsDefinedTextValues ON ClCxDemographicNoneExclusiveValues.CDDTVID = CxDemographicsDefinedTextValues.CDDTVID
  26.           WHERE     CLID IN ( 4586, 4587, 4588, 4589, 4590, 4591, 4592, 4593,
  27.                               10241, 10277, 10306, 10350, 10351, 10354, 10355,
  28.                               10376, 10377, 10591, 10593 )
  29.         ) TableDemographics
  30. ORDER BY CLID, CDID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement