【发布时间】:2018-06-14 15:15:41
【问题描述】:
我有一个返回以下结果的查询
Date Type
6/7/18 R104
6/7/18 Sunset
6/7/18 Rabbit-T
6/7/18 Sunset
6/8/18 R104
6/8/18 S400
6/9/18 Singer
6/9/18 Sunset
6/9/18 Rabbit-M
6/9/18 Sunset
6/9/18 Sunset
无论记录是什么,是否可以只提取最近日期(此处为 2018 年 6 月 9 日)的记录?
这是我的查询
SELECT
ot.sale_date AS "Sale Date"
, otr.type_33 AS "Type"
, ide.s_style AS "Style"
, att.att_color AS "Color"
FROM
SYSTEM.order_tracking as ot
LEFT OUTER JOIN SYSTEM.order_type as otr
on ot.clientID=otr.clientID and ot.salesperiod=otr.salesperiod and
ot.CUSTHBDT_UID=otr.CUSTHBDT_UID
LEFT OUTER JOIN SYSTEM.item_descriptions_East as ide
on otr.clientID=ide.clientID and otr.salesperiod=ide.salesperiod and
otr.CUSTHBDU_UID=ide.CUSTHBDU_UID
LEFT OUTER JOIN SYSTEM.attributes as att
on ide.clientID=att.clientID and ide.salesperiod=att.salesperiod and
ide.CUSTHBDV_UID=att.CUSTHBDV_UID
WHERE
ot.access_code = '1'
【问题讨论】:
-
用您正在使用的数据库标记您的问题。包含您正在使用的查询也很好。
-
ORDER BY "Date" DESC FETCH FIRST 1 ROW WITH TIES -
试过了。我的程序不喜欢 FETCH 或前 1 行
标签: sql