34,590
社区成员
发帖
与我相关
我的任务
分享
/* 第2句 */ update #Test set #Test.FAmount=(select sum(FAmount) from A where FType=6 and FID=#Test.FID) -- from #Test t1
Create Table #Test(FID int, FNumber varchar(200),FBillNo varchar(200),FAmount decimal(18,4))
create table a (ftype int,fid int,famount int)
go
update t1
set t1.FAmount=(select sum(FAmount) from A where FType=6 and FID=t1.FID)
from #Test t1
drop table #test,a
/*
(所影响的行数为 0 行)
*/
--try
update #Test set FAmount=(select sum(FAmount) from A where FType=6 and FID=t1.FID) from #Test t1
/* 第1句 */ Create Table #Test(FID int, FNumber varchar(200),FBillNo varchar(200),FAmount decimal(18,4))
insert into #Test(FID,FNumber,FBillNo)
select distinct t1.FID,t1.FCustomer,t2.FExplanation
from A t1 left join B t2 on t1.FContactID=t2.FID
where t1.FType=4
/* 第2句 */ update t1 set t1.FAmount=(select sum(FAmount) from A where FType=6 and FID=t1.FID) from #Test t1
/* 第3句 */ select * from #Test
/* 第4句 */ drop table #Test
-- 第2句 语法错误:
/* 第2句 */ update #Test t1 set t1.FAmount=(select sum(FAmount) from A where FType=6 and FID=t1.FID) -- from #Test t1
--恩。估计跟二楼说的一样
select distinct t1.FID,t1.FCustomer,t2.FExplanation
from A t1 left join B t2 on t1.FContactID=t2.FID
where t1.FType=4
看A表中是否有FID列。。。
--语法上似乎没什么错误。
create table a(ftype int,fid int,famount int)
go
Create Table #Test(FID int, FNumber varchar(200),FBillNo varchar(200),FAmount decimal(18,4))
go
insert into #Test(FID,FNumber,FBillNo)
select distinct t1.FID,t1.FCustomer,t2.FExplanation
from A t1 left join B t2 on t1.FContactID=t2.FID
where t1.FType=4
update t1
set t1.FAmount=(select sum(FAmount) from A where FType=6 and FID=t1.FID )
from #Test t1
select * from #Test
drop table #Test