请教一个简单的SQL语句

snower01 2005-02-21 10:37:52
数据库是ACCESS
id f_date f_xnew
1 2005-1-1 ……
2 2005-1-1 ……
3 2005-1-1 ……
4 2005-1-5 ……
5 2005-1-5 ……
……
现在,我想取出最后同一时间的内容,按照顺序进行排列。下面的SQL语句应该怎样写?
sql = "select * from 表 group by f_date order by f_date,id desc"
...全文
97 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
61 2005-02-22
  • 打赏
  • 举报
回复
select * from table where DatePart(day,f_date) = DatePart(day,(select max(f_date) from table)) order by id
redstorm11 2005-02-22
  • 打赏
  • 举报
回复
up
baiyunfei 2005-02-22
  • 打赏
  • 举报
回复
mark
skc_2004 2005-02-22
  • 打赏
  • 举报
回复
参与、学习
snower01 2005-02-21
  • 打赏
  • 举报
回复
已解决!
select * from table where f_date = (select max(f_date) from table) order by id desc
raline 2005-02-21
  • 打赏
  • 举报
回复
sql = "select * from 表名 order by f_date,id"
先按f_date排,再按id排
如果要倒序 sql = "select * from 表名 order by f_date desc,id desc"
order只要一个,desc是跟在要排序的段名后

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧