新手求救,请高手忙帮写个sql语句。 如表table:id city other score1 a 1 251 b 1 251 c 251 d 251 e 251 f 1 251 g 1 25如何查询"other"不为空的记录,然后按有“other”记录数最多的city排序。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 然后按有“other”记录数最多的city排序:举例说明 id city other score 1 a 1 25 1 a 1 25 1 b 25 1 d 25 1 a 25 1 b 1 25 1 a 1 25 如何查询"other"不为空的记录,然后按有“other”记录数最多的city排序。比如查询出来的是:a 3b 1 select city,count(*) from tt where other is not nullgroup by cityorder by count(*) SELECT city,COUNT(*) FROM yourTable WHERE other IS NOT NULL GROUP BY city ORDER BY 2 desc ◆ ◆ ◆ 有没有比SQL-Front还好一点的SQL客户端软件啊?大家都用什么来编辑SQL 查询某字段的值长度大于xxx的行吗? 求一个查询 mysql简单查询问题(关于查询条件) mysql编码转换 【完全新手请教】用c++开发MySQL程序使用什么技术好? SQLserver中的image类型在MYSQL中对应哪种类型 create table error 关于mysql 中文问题 character_set_server and character_set_database值均为latin1 DOS 环境下无法执行mysql命令 MySql存储过程参数问题
1 a 1 25
1 a 1 25
1 b 25
1 d 25
1 a 25
1 b 1 25
1 a 1 25 如何查询"other"不为空的记录,然后按有“other”记录数最多的city排序。
比如查询出来的是:
a 3
b 1
group by city
order by count(*)
FROM yourTable
WHERE other IS NOT NULL
GROUP BY city
ORDER BY 2 desc