Quantcast
Channel: SQL.ru: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 7251

Неожиданный результат

$
0
0
Привет всем.
Может кто знает, почему результаты выборок - разные?
declare @R table (x int)
declare @R2 table (x int)

insert into @R(x)
Values (0),(1),(2),(3);

insert into @R2(x)
Values (5),(1),(2),(3);

select l.x, r.x x2,coalesce(l.x,r.x) ,coalesce(r.x,l.x)
from @R l full join @r2 r on l.x = r.x
where coalesce(l.x,r.x) = coalesce(r.x,l.x)

select l.x, r.x x2,coalesce(l.x,r.x) ,coalesce(r.x,l.x)
from @R l, @r2 r
where coalesce(l.x,r.x) = coalesce(r.x,l.x)

Viewing all articles
Browse latest Browse all 7251