或者selct * from table1 where id=(select max(id)from table1)
select top 1 * from table1 order by id desc
set rowcount 1 select * from table1 order by id desc set rowcount 0
对不起,可能是我没说明白我的问题. 我是想问: 在如下表中ID NAME 1 A 2 A 3 A 1 B 2 B 1 C 问题是:如何能够找出表中NAME字段为A的记录中ID值为最大的那条记录.
变通一下吗! 1. set rowcount 1 select * from table1 where name='A' order by id desc set rowcount 0 2. select top 1 * from table1 where name='A' order by id desc 3. selct * from table1 where id=(select max(id)from table1 where name='A') 4.select t1.* from table1 t1 join (select id=max(id) from table1 where name='A')t2 on t1.id=t2.id 5. select t1.* from table1 t1,(select id=max(id) from table1 where name='A')t2 where t1.id=t2.id ...
select * from table1 order by id desc
set rowcount 0
我是想问:
在如下表中ID NAME
1 A
2 A
3 A
1 B
2 B
1 C
问题是:如何能够找出表中NAME字段为A的记录中ID值为最大的那条记录.
1.
set rowcount 1
select * from table1 where name='A' order by id desc
set rowcount 0
2.
select top 1 * from table1 where name='A' order by id desc
3.
selct * from table1 where id=(select max(id)from table1 where name='A')
4.select t1.* from table1 t1 join (select id=max(id) from table1 where name='A')t2 on t1.id=t2.id
5.
select t1.* from table1 t1,(select id=max(id) from table1 where name='A')t2 where t1.id=t2.id
...