SELECT
 *
FROM
 (
  SELECT 
   RegulationId, 
   RegulationName, 
   RegulationTypeName, 
   ConditionName, 
   OrganizationName, 
   CONVERT(varchar,RegulationCreateDate,120) AS RegulationCreateDate,
   RegulationStepName, 
   --RegulationStepStatusName,
   CASE
    WHEN CHARINDEX('<', RegulationStepStatusName) > 0
    THEN CONVERT(XML, RegulationStepStatusName, 1).value('.', 'nvarchar(max)')
    ELSE RegulationStepStatusName
   END AS RegulationStepStatusName,
   --SLA, 
   CASE
    WHEN CHARINDEX('<', SLA) > 0
    THEN CONVERT(XML, SLA, 1).value('.', 'nvarchar(max)')
    ELSE SLA
   END AS SLA,
   RegulationStep, 
   RegulationStepStatus, 
   RegulationNameVersion, 
   RegulationStatus,
   RegulationOrganizationId
  FROM 
   SISIMPU.[Transaction].View_RegulationMonitoring
 ) AS x
WHERE
 --x.RegulationStepName <> 'Finalisasi'
 x.RegulationStepStatusName NOT IN ('Completed', 'Cancel') AND RegulationOrganizationId IN
(18,
31,
34,
36,
37,
41,
98,
100,
101,
102,
103,
104,
107,
108,
109,
110,
111,
124,
125,
126,
127,
128,
129,
130,
131,
132,
133,
134,
135,
136,
139,
140,
142,
143,
144,
151,
154,
155,
156,
158,
159,
161,
165,
171,
172,
174,
175,
176,
178,
183,
184,
185,
186,
190,
191,
192,
193,
194,
195,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
210,
211,
212,
213,
214,
215,
216,
217,
218,
219,
220,
221,
222,
223,
224,
225,
226,
227,
228,
229,
230,
231,
232,
233,
234,
235,
236,
237,
238,
239,
240,
241,
242,
243,
244,
245,
246,
247,
248,
251)