能不能单纯通过SQL实现...
main表 两个字段id、team
能不能按team中某数据出现次数由高到低排序并列出出现的次数例如id | team | count
-----------------------
2 |team2 | 10
1 |team1 | 8
3 |team3 | 5
main表 两个字段id、team
能不能按team中某数据出现次数由高到低排序并列出出现的次数例如id | team | count
-----------------------
2 |team2 | 10
1 |team1 | 8
3 |team3 | 5
from main a
order by [count] desc
原谅新手SQL不太会
但是当from 子句里有多个 main表时,就必须指定别名 这样数据库才可以区分两个表
create table main(id int identity,team varchar(10))
go
insert into main select 'term1'
GO 3
insert into main select 'term2'
GO 4
insert into main select 'term3'
GO 5--select id,team,(select count(1) [count] from main b where a.team=b.team group by team )[count]
from main a
order by [count] desc 我不信你这个就不用结分
from main a,(select team ,count(1) [count] from main b group by team ) b
where a.team=b.team
order by b.[count] desc
from main a
order by [count] desc
FROM `main`
GROUP BY `team`,`ip`
ORDER BY count DESC 孤陋寡闻.一直以为SQL语句放哪都差不多~~