C# 使用C应用程序在asp.net中出现Sql查询错误
我只是尝试使用这个查询按数据网格显示细节C# 使用C应用程序在asp.net中出现Sql查询错误,c#,sql,C#,Sql,我只是尝试使用这个查询按数据网格显示细节 select P.Sitename as Site ,P.Vendorname as Vendor ,P.POno,PS.Itemcode as ItemCode ,sum(PS.Quantity) as Qty ,sum(PS.Basic) as Basic ,Sum(PS.DiscountAmt) as [Disc Amt] ,sum(PS.PFAmt) as [PF Amt] ,sum(PS.EDAmt) as [ED Amt] ,sum(PS.
select
P.Sitename as Site
,P.Vendorname as Vendor
,P.POno,PS.Itemcode as ItemCode
,sum(PS.Quantity) as Qty
,sum(PS.Basic) as Basic
,Sum(PS.DiscountAmt) as [Disc Amt]
,sum(PS.PFAmt) as [PF Amt]
,sum(PS.EDAmt) as [ED Amt]
,sum(PS.VATCSTAmt) as [VATCST Amt]
,sum(PS.Netamt) as Total
,I.Itemname as Itemname
,I.UOM as UOM
from tbl_Itemmaster I, tbl_Purchaseorder_sub PS,tbl_Purchaseorder P
where P.POdate between '8/30/2012' and '8/31/2012'
and PS.status in (4,5)
and I.Itemidentify=Ps.ITemcode
and PS.pono=p.POno
group by PS.Itemcode,P.Sitename,P.Vendorname,I.Itemname,I.UOM
order by Site,Vendor,ItemCode
但是,我在执行这个过程中遇到了一个错误
"Column 'tbl_Purchaseorder.POno' is invalid in the select list because
it is not contained in either an aggregate function or the GROUP BY clause."
有人能告诉我如何更正吗您需要通过CLUSE将POno添加到组中 差不多
select P.Sitename as Site,
P.Vendorname as Vendor,
P.POno,
PS.Itemcode as ItemCode,
sum(PS.Quantity) as Qty,
sum(PS.Basic) as Basic,
Sum(PS.DiscountAmt) as [Disc Amt],
sum(PS.PFAmt) as [PF Amt],
sum(PS.EDAmt) as [ED Amt],
sum(PS.VATCSTAmt) as [VATCST Amt],
sum(PS.Netamt) as Total ,
I.Itemname as Itemname,
I.UOM as UOM
from tbl_Itemmaster I,
tbl_Purchaseorder_sub PS,
tbl_Purchaseorder P
where P.POdate between '8/30/2012'
and '8/31/2012'
and PS.status in (4,5)
and I.Itemidentify=Ps.ITemcode
and PS.pono=p.POno
group by PS.Itemcode,
P.Sitename,
P.Vendorname,
I.Itemname,
I.UOM,
P.POno <-- You need to add this to your query
order by Site,
Vendor,
ItemCode
您需要通过CLUSE将POno添加到组中 差不多
select P.Sitename as Site,
P.Vendorname as Vendor,
P.POno,
PS.Itemcode as ItemCode,
sum(PS.Quantity) as Qty,
sum(PS.Basic) as Basic,
Sum(PS.DiscountAmt) as [Disc Amt],
sum(PS.PFAmt) as [PF Amt],
sum(PS.EDAmt) as [ED Amt],
sum(PS.VATCSTAmt) as [VATCST Amt],
sum(PS.Netamt) as Total ,
I.Itemname as Itemname,
I.UOM as UOM
from tbl_Itemmaster I,
tbl_Purchaseorder_sub PS,
tbl_Purchaseorder P
where P.POdate between '8/30/2012'
and '8/31/2012'
and PS.status in (4,5)
and I.Itemidentify=Ps.ITemcode
and PS.pono=p.POno
group by PS.Itemcode,
P.Sitename,
P.Vendorname,
I.Itemname,
I.UOM,
P.POno <-- You need to add this to your query
order by Site,
Vendor,
ItemCode
如果回答了您的问题,请选择此作为您的答案question@user1632377,有一个更好的表达感谢的方式。请参阅,如果回答了您的问题,请选择此作为您的答案question@user1632377,有一个更好的表达感谢的方式。看见