我有两个表,我想在我的SQL中加入它们来检索结果

时间:2017-01-24 20:49:16

标签: sql

我有两个表ork3,ork2我想总结列k1连接表ork3>>>>>>>>>>

2 个答案:

答案 0 :(得分:0)

这应该做你想要的:

SELECT [name]
    , [date]
    , [dep]
    , [sum(k1)]
FROM   ork3
      INNER JOIN
              (SELECT [name]
                   , SUM([k1]) AS [sum(k1)]
               FROM   ork2
               GROUP BY [name]) AS ork2 ON ork3.[name] = ork2.[name];

答案 1 :(得分:0)

你可以做;

Select name, sum(k1) From ork3 o3 Inner Join ork2 o2 On o2.name = o3.name group by o3.name;