selset * from table where 时间>=getdata() group by 员工 having min(时间) order by 时间 desc
补充:时间>=getdata() 这个时间精确到天就可以了!
[/Quote]
消息 8121,级别 16,状态 1,第 1 行
HAVING 子句中的列 '时间' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。
[Quote=引用 20 楼 kk706 的回复:]
select name ,min(time),''
from t
group by name
having time >= convert(varchar(10),getdate(),112)
and time < dateadd(day,1,convert(varchar(10),getdate(),112));
112 还是 21 啥的记不清了,查一下吧
[/Quote]
消息 8121,级别 16,状态 1,第 1 行
HAVING 子句中的列 'time' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。
员工 时间 状态 备注
张三 2010-11-24 15:30:03 登陆 。。。。。
李四 2010-11-23 14:20:10 登陆 。。。。。
,
只取当天最早的一条、重复的不显示,最新更新的记录要显示在最前面??????
[/Quote]
只取当天最早的一条、重复的不显示
=============================
你这么表述一般人都会误解的· “重复的不显示” 改成“重复的只显示最早的那条”……
select * from tb group by name having min(time) order by time desc 大概是这样 ,自己去改
select name ,min(time),''
from t
group by name
having time >= convert(varchar(10),getdate(),112)
and time < dateadd(day,1,convert(varchar(10),getdate(),112));