Hi
(Select Case (select count(*) from tbl1 T where T.num = T0.num ) when 0 then
HCode=STUFF
(
(
SELECT ', '+ CAST(A0.[aCode] AS VARCHAR(MAX))
FROM O A0
INNER JOIN I A1 ON A0.[AEntry] = A1.[SEntry]
FOR XMl PATH('')
),1,1,''
) else '2' end)
from tbl5 t0
Thanks
December 15, 2021 at 11:14 am
Hi
(Select Case (select count(*) from tbl1 T where T.num = T0.num ) when 0 then HCode=STUFF ( ( SELECT ', '+ CAST(A0.[aCode] AS VARCHAR(MAX)) FROM O A0 INNER JOIN I A1 ON A0.[AEntry] = A1.[SEntry] FOR XMl PATH('') ),1,1,'' ) else '2' end)
from tbl5 t0
Thanks
What is your question?
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
December 15, 2021 at 11:15 am
Hi
Error is coming Invalid column HCode
Thanks
December 15, 2021 at 11:22 am
Hi
Error is coming Invalid column HCode
Thanks
Still no question.
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
Maybe extract the constant and put the correlated subquery in the FROM clause as a CROSS APPLY
declare @vmax_var varchar(max)=
(SELECT STUFF((SELECT ', ' + CAST(A0.[aCode] AS VARCHAR(MAX))
FROM O A0
JOIN I A1 ON A0.[AEntry] = A1.[SEntry]
FOR XMl PATH('')),1,1,''));
Select HCode=case when t.t_count=0 then @vmax_var else '2' end
from tbl5 t0
cross apply (select count(*)
from tbl1 T
where T.num = T0.num) t(t_count);
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply