通过大多数插入的食物名称从食物表顺序中取食物名称 [英] fetch food name from food table order by most inserted food name
本文介绍了通过大多数插入的食物名称从食物表顺序中取食物名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过大多数插入的食物名称从食物表顺序中获取食物名称。
how to fetch food name from food table order by most inserted food name.
推荐答案
这里尝试这样的事情,因为我不完全知道该列和表名,所以在这里:
Here try something like this, Since I don't exactly know the column and table names, So here it goes:
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...
一般来说,要编写这样的查询,你应该分解你的意思,所以:
...插入食物名称(获取食物名称的数量以查看最多插入的食物名称):
Generally to write such queries you should break down what you are saying, so:
"...inserted food name" (get the count of food name to see which is most inserted):
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.
这篇关于通过大多数插入的食物名称从食物表顺序中取食物名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文