当前位置: 代码迷 >> ASP.NET >> 这个SQL语句应该怎么写
  详细解决方案

这个SQL语句应该怎么写

热度:8430   发布时间:2013-02-25 00:00:00.0
这个SQL语句应该如何写?
想达到这个效果,
select a.pid,a.scmid,a.productmodel,a.amountin,sum( b.AmountIn)as num1 
from Product_Stock a, Product_In b
where a.scmid=b.scmid

运行提示
服务器: 消息 8120,级别 16,状态 1,行 1
列 'a.Pid' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
服务器: 消息 8120,级别 16,状态 1,行 1
列 'a.ProductModel' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
服务器: 消息 8120,级别 16,状态 1,行 1
列 'a.AmountIn' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。

应该如何写啊?谢谢了

------解决方案--------------------------------------------------------
少了GROUP BY 子句:
select a.pid,a.scmid,a.productmodel,a.amountin,sum( b.AmountIn)as num1
from Product_Stock a, Product_In b 
where a.scmid=b.scmid group by a.pid,a.scmid,a.productmodel,a.amountin
按你的要求自己改就可以了
  相关解决方案