数据库视图写法求助
两个表
字段 类别 数值 字段 数值
a b 555 a 666
a c 666 a 777
a d 777 a 888
a e 888 f 999
怎样用视图算出表1所有字段为a的数值总和和表2字段为a的数值总和 数据库
[解决办法]
create view V_name
as
with a1 as
(select columna,sum(columnc) c1 from t group by columna)
,a2 as
(select columna1,sum(columnc) c2 from t1 group by columna1)
select a1.columna,a1.c1,a2.c2 from a1 inner join a2
on a1.columna=a2.columna1
没有在ssms里面写。大概这样