日期:2014-05-17 浏览次数:20768 次
if object_id('student') is not null drop table student
go
create table student (idno char(10) PRIMARY KEY ,name varchar(20) ,sex varchar(4), createtime datetime,status tinyint )
insert student
select '001','张三','男','20130401','1' union all
select '002','李三','女','20130409','1' union all
select '003','王三','男','20130501','1' union all
select '004','张五','女','20130301','1' union all
select '005','陈六','男','20130512','0'
---select * from student
select * from student
where createtime in (select MAX(createtime) from student where status=1)