求一查询语句,马上给分 怎样得出表按某字段降序排序后姓名为‘张三’的记录在降序表中的位置在第几? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select count(*) from 表名字 where 列名字> ( select 列名字 from 表名字 where name='张三') declare @t table(id int,name varchar(14))insert @t select 1,'李四'insert @t select 2,'张三'insert @t select 3,'李四B'insert @t select 4,'李四A'insert @t select 5,'李四C'insert @t select 6,'李四D'insert @t select 7,'李四E'insert @t select 8,'李四F'insert @t select 9,'张三H'insert @t select 10,'张三K'select id,name,排名=(select count(*)+1 from @t b where b.name>a.name) from @t a order by name desc------------------------id name 排名10 张三K 19 张三H 22 张三 38 李四F 47 李四E 56 李四D 65 李四C 73 李四B 84 李四A 91 李四 10 插入数据疑惑 2台mysql数据库不能同步的问题 插入新的记录 .net 访问 带有输出参数的存储过程,为什么无法获得输出参数值? C语言开发mysql客户应用程序环境的搭建问题 如何实现列常量的查询 关于JSP连MYSQL的问题 还是没有解决中文问题。postgres中是中文,web页面乱码 哪有mysql-front2.5? 大数据量下更新中文出错,何解? 苍天啊,为什么会出现这种问题~~~@_@ 麻烦啊。来帮帮我把。。。
insert @t select 1,'李四'
insert @t select 2,'张三'
insert @t select 3,'李四B'
insert @t select 4,'李四A'
insert @t select 5,'李四C'
insert @t select 6,'李四D'
insert @t select 7,'李四E'
insert @t select 8,'李四F'
insert @t select 9,'张三H'
insert @t select 10,'张三K'select id,name,排名=(select count(*)+1 from @t b where b.name>a.name) from @t a order by name desc------------------------
id name 排名
10 张三K 1
9 张三H 2
2 张三 3
8 李四F 4
7 李四E 5
6 李四D 6
5 李四C 7
3 李四B 8
4 李四A 9
1 李四 10