select col1,col2,..,max(add_date) as date from table1 group by col1,col2,..
select add_date=max(add_date) as date from table1
select *,date=max(add_date) from table1
select * from table where add_date= select top 1 add_date from table group by add_date order by add_date
select * from table1 where datediff("d",add_date ,isnull((select max(add_date) from table1),getdate()))=0
select *,max(add_date) as maxdate from table1 group by 字段名字
select * from table1 a where add_date=( select max(add_date) from table1)
select id,max(add_date) as date from table1 group by id
如果你的add_date已经格式化到日期(就象你举例的)select * from table1 a where add_date=( select max(add_date) from table1)如果没有格式化到日期:select * from table1 a where datediff(day,add_date,( select max(add_date) from table1))=0
谢谢大家的帮忙 查最后一天的日期是可以,但现在有一个问题就是在table1表中userid字段必须要跟session("username")相同,sql语句如下: select * from table1 where userid='"&session("username")&"' and add_date=(select max(add_date) from table1) 这样就造成了userid相同而最新日期就不能匹配了,我必须要userid和add_date同时匹配,如何修改呀
group by col1,col2,..
select top 1 add_date from table group by add_date order by add_date
from table1
where datediff("d",add_date
,isnull((select max(add_date) from table1),getdate()))=0
group by 字段名字
select max(add_date) from table1)
group by id
select max(add_date) from table1)如果没有格式化到日期:select * from table1 a where datediff(day,add_date,(
select max(add_date) from table1))=0
查最后一天的日期是可以,但现在有一个问题就是在table1表中userid字段必须要跟session("username")相同,sql语句如下:
select * from table1 where userid='"&session("username")&"' and add_date=(select max(add_date) from table1)
这样就造成了userid相同而最新日期就不能匹配了,我必须要userid和add_date同时匹配,如何修改呀