子查询多行如何? [英] Sub Query More than one row How ?
问题描述
当我运行这个子查询时
when I run this sub query
SELECT bovd.CusCode, bovd.RecQty from BookOrdVehDetail bovd INNER JOIN VehicleSalesDetail vsd ON bovd.CusCode = vsd.CusCode
WHERE (SELECT sum(cast(bovd.Qty AS int)) From BookOrdVehDetail bovd Group By bovd.CusCode )
>
(select count(vsd.RecNo) New FROM VehicleSalesDetail vsd Group By Vsd.CusCode )
错误此
Error This
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
< br $>
子查询1此图像中的结果和子查询2和结果此>>>>> >>
http://postimg.org/image/8w2irf36p/ [ ^ ]
http://postimg.org/image/vyt1ql4o1/ [ ^ ]
http://postimg.org/image/p9miakjc1/ [ ^ ]
i认为不应该有不止一行
im混淆了这是怎么来的..... <
我该怎么做才能使这个查询 sum(Qty)>计数(发票)
Subquery 1 Result in this image and Sub QUery 2 and Result this >>>>> >>
http://postimg.org/image/8w2irf36p/[^]
http://postimg.org/image/vyt1ql4o1/[^]
http://postimg.org/image/p9miakjc1/[^]
i think there is more than one row should not come
i m confuse how this is come there.....
And what should i do for make this query sum(Qty) > Count(invoice)
推荐答案
试试这个...
try this...
SELECT bovd.CusCode, bovd.RecQty from BookOrdVehDetail bovd INNER JOIN VehicleSalesDetail vsd ON bovd.CusCode = vsd.CusCode
WHERE (SELECT sum(cast(bovd1.Qty AS int)) From BookOrdVehDetail bovd1 Group By bovd1.CusCode having bovd.CusCode=bovd1.CusCode)
>
(select count(vsd1.RecNo) New FROM VehicleSalesDetail vsd1 Group By Vsd1.CusCode having vsd1.CusCode=vsd.CusCode)
快乐编码!
:)
Happy Coding!
:)
试试这个querry之后通过..........删除组nd在尝试
try this querry after removing group by .......... nd do tell me the result after trying
这篇关于子查询多行如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!