本文介绍了通过大多数插入的食物名称从食物表顺序中取食物名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过大多数插入的食物名称从食物表顺序中获取食物名称。
how to fetch food name from food table order by most inserted food name.
推荐答案
SELECT FoodName, COUNT(FoodName) FROM dbo.FoodTable GROUP BY FoodName
ORDER BY COUNT(FoodName) DESC
如果你想要不同的东西,请告诉我。
Azee ...
Let me know, if you expected something different.
Azee...
select foodname, count(foodname) as c from foodtable group by foodname
按大多数插入来获取食物名称顺序......(在复合查询中使用上述内容):
"fetch food name order by most inserted..." (uses the above in a compound query):
select t.foodname from
( select foodname, count(foodname) as c from foodtable group by foodname )
as t order by t.c desc
现在你可以优化它,但它是一个很好的起点。
Now you can optimize this, but it's a good place to start.
这篇关于通过大多数插入的食物名称从食物表顺序中取食物名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!