如图表:TBL1
求表TBL1中type为1中ID最大的一条数据,select语句改怎么写
要求要是一条sql语句
解决方案
70
select * from
TbL1
where
id in
(
select max(ID) as ID from TBL1 where Type =1
)
TbL1
where
id in
(
select max(ID) as ID from TBL1 where Type =1
)
30
select *
from TBL1 t
where type=1
and not exists (select 1 from TBL1 where type=1 and ID>t.ID )
from TBL1 t
where type=1
and not exists (select 1 from TBL1 where type=1 and ID>t.ID )