SQL查询(Distict和count) [英] Sql query(Distict and count)
本文介绍了SQL查询(Distict和count)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要获取菜肴名称,并计算其数量b /两个日期。这是我的代码 -
SELECT COUNT(Qty)FROM(SELECT Dishes FROM Temp_Dishes其中Dates ='+ dd.ToString(dd-MM-yyyy )+'GROUP BY Dishes)p
错误消息msg是 - 没有给出一个或多个必需参数的值。
I want to fetch dishes name with count their quantity b/two dates. this is my code--
SELECT COUNT(Qty) FROM (SELECT Dishes FROM Temp_Dishes where Dates='" + dd.ToString("dd-MM-yyyy") + "' GROUP BY Dishes) p
the error msg is-"No value given for one or more required parameters."
推荐答案
你已经提到了你的表,
但是我认为,你应该在你的内部查询中获取数量,如果你想计算数量字段
你应该在内部查询中获取它!
You've mentioned your tables ,
but i think , you should fetch Qty in your inner query , if you want to count the qty field
you should fetch it in the inner query !
尝试类似于此的查询。希望它有所帮助。
Try the query similar to this. Hope it helps.
SELECT Dishes,SUM(qty) FROM Temp_Dishes where Dates between @startdate and @enddate GROUP BY Dishes
而不是
dd.ToString("dd-MM-yyyy")
写
write
dd.ToString("yyyy-MM-dd")
快乐编码!
:)
Happy Coding!
:)
这篇关于SQL查询(Distict和count)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文