求条sql语句 表结构(sn int,id int,time datetime)求 id=1、time最大的记录的sn 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select top 1 sn from 表 where id=1 order by time desc select t.sn from 表 t where t.id=1 and not exists(select 1 from 表 where id=t.id and time>t.time) select id,max(b) sn from [表] where id=1 group by id :)select * from [表] where [time]=(select max([time]) from [表] where id=1 group by id) select snfrom 表where id=1 and time=(select max(time) from 表 where id=1 group by id) 关于数据库查询的问题? SQL语句日期相加问题 如何完全拆卸sqlserver 2005 sql报表服务的问题!!(在线等) 急问,这种统计语句怎么写??? 怎么锁住一条记录 请问发生误操作后,如何将数据库恢复到以前的时间点。请各位高手帮忙 老师给我了一个作业,谁能帮帮我啊 ? 有问题的查询。 请各位大哥帮帮忙! SQL Server 查询 出现怪问题 新手请教:如果某字段记录相同,怎样根据日期查询最后一条记录?
t.sn
from
表 t
where
t.id=1
and
not exists(select 1 from 表 where id=t.id and time>t.time)
select * from [表] where [time]=(select max([time]) from [表] where id=1 group by id)
from 表
where id=1 and time=(select max(time) from 表 where id=1 group by id)