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

时间:2023-01-04 15:29:53

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

i have two table ork3,ork2 i want to sum column k1 join table ork3>>>>>>>>>>

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

2 个解决方案

#1


0  

This should do what you want:

这应该做你想要的:

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];

#2


0  

You could do;

你可以做;

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

#1


0  

This should do what you want:

这应该做你想要的:

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];

#2


0  

You could do;

你可以做;

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