Answer the question
In order to leave comments, you need to log in
What does (tt2) mean here: from @temp1 tt2?
I can't figure it out in this part of the query:
insert into @temp
select [Idchain], [suc], [unsuc],
[int]
from (
select distinct [Idchain],
[suc] = case
when exists (select *
from @temp1 tt2
where tt2.idchain = tt1.idchain
and ([CallResult] = 5 or [CallResult] = 18)) then 1
else null
end,
[unsuc] = case @slist
when 1 then
case
when not exists (select *
from @temp1 tt2
where tt2.idchain = tt1.idchain
and ([CallResult] = 5 or [CallResult] = 18)) then 1
else null
end
when 2 then
case
when not exists (select *
from @temp1 tt2
where tt2.idchain = tt1.idchain
and ([CallResult] = 5 or [CallResult] = 18 or lenqueue <= @xline)) then 1
else null
end
end,
[int] = case
when Interval = 1 then cast(floor(cast (datetimestart as float)) as datetime)
when Interval= 7 then cast(floor(cast (datetimestart as float) - datepart (dw, datetimestart) + 1) as datetime)
when Interval = 12 then cast (cast(datepart (yy, datetimestart) as nvarchar (4)) + '- ' + cast(datepart (mm, datetimestart) as nvarchar (2)) + '-01' as datetime)
else
cast(
( floor( cast(datetimestart as float) * @mnog) / @mnog -
floor(cast(datetimestart as float))
as datetime)
end
from @temp1 tt1
) tb1
I don't understand what (tt1) means here : select *
from @temp1 tt2
where tt2.idchain = tt1.idchain
or here: select *
from @temp1 tt2
where tt2.idchain = tt1.idchain
Answer the question
In order to leave comments, you need to log in
tt2 is an alias (synonym) for the name of the table temp1. Convenient for reducing requests, but you can do without it, but everywhere you have to replace tt2 with temp1, respectively
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question