Need to get order qty of the minimum ADATE
我使用下面的查询并获得12条记录。现在我想选择最小ADATE的orderqty,即06-NOV-2018(2018-11-06)。 对于每个客户(将获得多个记录),我需要获取最小ADATE列的Order_Qty。
select
Customer ,
OrderID ,
LocationID ,
Order_Qty,Sent_date ,ADATE
from
(
select
OrderID ,
LocationID ,
Sent_date ,
Order_Qty ,
Customer ,
TimeStampA
from ARC_TBL
)
obn
inner join
(
select
ADATE ,TimeStampA
from trackTBL snt
)snt
on obn.TimeStampA = snt.TimeStampA
where Customer='ABC' and OrderID='XYZ100' and Sent_date='2018-11-18' and LocationID='250';
答案 0 :(得分:0)
SELECT QTY, ADATE
FROM table
ORDER BY ADATE
FETCH FIRST 1 ROW ONLY
详细说明您的问题,您将获得更好的答案。