select 语句 具体问题具体分析,要是有数据参考,可以考虑是否使用别的方法。top 3 就不感觉不错了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 create table student(id int, name varchar(10), cj int, rq datetime)insert student select 1, 'AA', 68, '2007-01-02'insert student select 2, 'BB', 88, '2007-01-02'insert student select 3, 'CC', 90, '2007-01-02'insert student select 4, 'DD', 65, '2007-01-02'insert student select 5, 'EE', 70, '2007-01-02'insert student select 1, 'AA', 78, '2007-02-02'insert student select 2, 'BB', 80, '2007-02-02'insert student select 4, 'DD', 90, '2007-02-02'insert student select 5, 'EE', 84, '2007-02-02'select * from student as tmpwhere (select count(*) from student where convert(char(7), rq, 120)=convert(char(7), tmp.rq, 120) and cj>tmp.cj)<3order by rq, cj desc--resultid name cj rq ----------- ---------- ----------- ------------------------------------------------------ 3 CC 90 2007-01-02 00:00:00.0002 BB 88 2007-01-02 00:00:00.0005 EE 70 2007-01-02 00:00:00.0004 DD 90 2007-02-02 00:00:00.0005 EE 84 2007-02-02 00:00:00.0002 BB 80 2007-02-02 00:00:00.000(6 row(s) affected) 大家都来讨论一下 SQL 语句的执行效率问题 我的数据库A的日志现在已达2GB,如何使它变小? 急! 存储过程使用OPENDATASOURCE出现错误7405,很急呀 LogExplorer连接问题 求助一个Sql语句,找出一个字段重复的纪录! 请问,如何用sql语句实现排除问题! SQL对树型数据表的操作 是否有什么设置限制了select top 10 from table这种语句? VFP小问题,请各位大侠帮忙! 高手们挑战一下啊,日期格式的问题 sqlserver2005temp库无法打开
create table student(id int, name varchar(10), cj int, rq datetime)
insert student select 1, 'AA', 68, '2007-01-02'
insert student select 2, 'BB', 88, '2007-01-02'
insert student select 3, 'CC', 90, '2007-01-02'
insert student select 4, 'DD', 65, '2007-01-02'
insert student select 5, 'EE', 70, '2007-01-02'insert student select 1, 'AA', 78, '2007-02-02'
insert student select 2, 'BB', 80, '2007-02-02'
insert student select 4, 'DD', 90, '2007-02-02'
insert student select 5, 'EE', 84, '2007-02-02'select * from student as tmp
where
(select count(*) from student
where convert(char(7), rq, 120)=convert(char(7), tmp.rq, 120) and cj>tmp.cj)<3
order by rq, cj desc--result
id name cj rq
----------- ---------- ----------- ------------------------------------------------------
3 CC 90 2007-01-02 00:00:00.000
2 BB 88 2007-01-02 00:00:00.000
5 EE 70 2007-01-02 00:00:00.0004 DD 90 2007-02-02 00:00:00.000
5 EE 84 2007-02-02 00:00:00.000
2 BB 80 2007-02-02 00:00:00.000(6 row(s) affected)