110,561
社区成员
发帖
与我相关
我的任务
分享
select * from u1;
select * from u2;
select u1.name,(u1.tid-isnull(u2.tid,0)) as tid from u1
left join u2 on u1.name=u2.name
SELECT a.Column1,(ISNULL(b.Num,0)-a.Num) Num FROM dbo.A1 a LEFT JOIN dbo.B1 b ON a.Column1=b.Column1
if object_id(N'tempdb..#temp1',N'U') is not null
drop table #temp1;
select * into #temp1 from [A] where 1 <> 1;
declare @Name varchar(10);
declare @CountA int;
declare @CountB int;
declare c1 cursor for select * from [A];
open c1;
fetch next from c1 into @Name, @CountA;
while @@FETCH_STATUS = 0
begin
set @CountB = 0;
select @CountB = [Count] from [B] where [Name] = @Name;
insert into #temp1 values(@Name,@CountA-@CountB);
fetch next from c1 into @Name, @CountA;
end
close c1;
deallocate c1;
select * from #temp1;