是这样的,我有 3 张表 A,B,C
其中 A的结构式这样的
money,consig,costname,reB的结构式这样的
ID,consigC的结构式这样的
ID,shouldmoney,date,isCloseb与c式主外键关系我想做的事 根据条件(date为时间类型,isClose=‘1’) 查出 B,C量表的consig和shouldmoney 付给A表的consig和money(查到多少付多少),其中costname和re是从页面传来的也要附给A表
求高手 解答,谢啦,在线等
其中 A的结构式这样的
money,consig,costname,reB的结构式这样的
ID,consigC的结构式这样的
ID,shouldmoney,date,isCloseb与c式主外键关系我想做的事 根据条件(date为时间类型,isClose=‘1’) 查出 B,C量表的consig和shouldmoney 付给A表的consig和money(查到多少付多少),其中costname和re是从页面传来的也要附给A表
求高手 解答,谢啦,在线等
as
(
select SUM(consig) consig,SUM(shouldmoney) shouldmoney
from
B inner join C on B.ID=C.ID
where C.date=@date and C.isClose='1'
)
select consig,shouldmoney,@costname,@re
into A
from cte
with cte
as(
select SUM(case(consig as int/float) consig,SUM(shouldmoney) shouldmoney
from B inner join
C on B.ID=C.ID where C.date=@date and C.isClose='1')
select consig,shouldmoney,@costname,@re into A from cte