SQL语句建立视图,涉及到两个表
发布网友
发布时间:2023-07-09 05:29
我来回答
共2个回答
热心网友
时间:2024-12-14 09:08
create view V_member as
select * from (select
a.memberid,a.membername,a.vocation,a.initpoint,a.addpoint,a.adj,a.remark,
--第一列
b.dkp,
--第二列
(a.initpoint+a.addpoint+a.adj-b.dkp)as dkp2 from member a
left join
--计算第二张表的相同名称人员的dkp总和
(select membername,sum(dkp)as dkp from expense group by membername) b on a.menbername=b.membername)tbl
热心网友
时间:2024-12-14 09:08
create view vw_member
as
select a.memberid,a.membername,a.vocation,a.initpoint,a.addpoint,a.adj,a.remark,b.dkp, (a.initpoint+a.addpoint+a.adj-b.dkp)as dkp2 from member a
left join (select membername,sum(dkp)as dkp from expense group by membername)as b
on a.menbername=b.membername