【发布时间】:2014-04-11 18:29:20
【问题描述】:
我在 Access 2013 中有一份打印设备日志的报告。每件设备都列出了一堆日期。我只想打印每件设备的最新日期。我已经搜索了互联网和这个网站,但没有运气。因此,任何建议将不胜感激。 我的 SQL 语句是: SELECT dbo_eq_location_transfer_d.equipment_id,dbo_equipment.description,dbo_eq_location_transfer_d.transaction_no,dbo_eq_location_transfer_d.job_no,dbo_jobs.description,dbo_eq_location_transfer_d.date_booked,dbo_eq_location_transfer_d.delivery_time,dbo_eq_location_transfer_d.line_no,dbo_eq_location_transfer_d.row_modified_by,dbo_eq_location_transfer_d.comment FROM (dbo_eq_location_transfer_d 内部联接 dbo_jobs ON dbo_eq_location_transfer_d.job_no = dbo_jobs.job_no) 内部联接 dbo_equipment ON dbo_eq_location_transfer_d.equipment_no = dbo_equipment.equipment_no ORDER BY dbo_eq_location_transfer_d.equipment_id, dbo_eq_location_transfer_d.transaction_no;
date_booked 字段是我试图缩小范围的日期字段。我有一个有效的简单 SQL 查询,我一直在尝试将其复制到 about SQL 中,但似乎无法使其网格化。这是: 选择 [dbo_eq_location_transfer_d.equipment_no],Max(dbo_eq_location_transfer_d.date_booked) AS [“最新日期”] FROM dbo_eq_location_transfer_d GROUP BY [dbo_eq_location_transfer_d.equipment_no];
【问题讨论】:
-
您能否进行访问
GROUP BY查询,为您提供每件设备的Max()日期? -
我已经尝试过了,但我似乎找不到在哪里这样做?
-
嗯,需要确定的问题...您的意思是您只想要该设备的一行并且它应该显示最近的日期?还是您的意思是要打印该设备的所有行,但只打印最新日期?
-
我只想为设备打印一行,它应该显示最近的日期。