|
阅读:436回复:4
[讨论]问个SQL语句,不使用存储过程得:(
某数据表(表名:access)中有如下字段:
xxx_id 1 1 2 2 2 1 3 1 2 3 3 3 3 1 1 要是按照XXX_id进行分组,同时,按照每组中xxx_id的个数进行排序(desc) DBMS:mysql 要求不使用存储过程实现 咋办??? oooo,松柏,偶RP又出问题了,救命 [ 2005-07-25 13:42:37 lijiannan_1981 修改 ] [ 2005-07-25 13:44:28 lijiannan_1981 修改 ] |
|
|
|
1C#
发布于:2005-07-25 13:38
Re:[讨论]问个SQL语句,不使用存储过程得:(
select count(xxx_id) from table goup by xxx_id order by count(xxx_id) desc
或 select count(xxx_id) from table goup by xxx_id order by 1 desc |
|
|
|
2C#
发布于:2005-07-25 13:47
Re:[讨论]问个SQL语句,不使用存储过程得:(
mysql 测试
create table tt( id int ); insert ..... mysql> select * from tt; +------+ | id | +------+ | 1 | | 1 | | 1 | | 2 | | 2 | | 3 | | 3 | | 4 | | 4 | | 4 | +------+ 10 rows in set (0.00 sec) 结果: mysql> select id,count(id) as cid from tt group by id order by cid desc; +------+-----+ | id | cid | +------+-----+ | 1 | 3 | | 4 | 3 | | 2 | 2 | | 3 | 2 | +------+-----+ 4 rows in set (0.00 sec) 不知道是不是楼主想要的~~ |
|
|
|
3C#
发布于:2005-07-25 13:48
Re:[讨论]问个SQL语句,不使用存储过程得:(
晕,检柏真快~~~ |
|
|
|
4C#
发布于:2005-07-25 13:50
Re:[讨论]问个SQL语句,不使用存储过程得:(
明白
谢谢2位了 |
|
|