我有两个表tbl_sbc和tbl_jdf,两个表都有“用户”和“访问”字段。 我想基于来自tbl_sbc和tbl_jdf的用户相等性创建一个新表,并总结访问。
示例
tbl_sbc
User Access
Foo 20
Bar 5
tbl_jdf
User Access
Foo 35
Beef 50
输出
User Access
Foo 55
Bar 5
Beef 50
我将如何去做?我似乎无法总结这些值
答案 0 :(得分:2)
你在这里
Select User, Sum(Access) As Total from
(Select User , Access from tbl_sbc
Union All
Select User , Access from tbl_jdf)
Group by User
order by user desc