I would like to return the first occurance of a record. The first occurance is date driven. Searched on message boards and internet and saw a few different ways to tackle this. Is using the ROWNUM = 1 the way to do it? If not, what is the recommendation solution?
Returns this data set:
Repository Order ID Date Ordered Date Shipped Lag Time
BILLING 4043 12/01/2008 00:00:00 12/01/2008 00:00:00 0
BILLING 4043 12/01/2008 00:00:00 12/02/2008 00:00:00 1
But I only want it to return the first occurrence (the first time the order was placed/shipped).
Repository Order ID Date Ordered Date Shipped Lag Time
BILLING 4043 12/01/2008 00:00:00 12/01/2008 00:00:00 0
I tried using min(s.SHIP_DATE ) but that still returned the same result set.
Any help is very appreciated.
Thanks.
Code:
SELECT 'BILLING' as "Repository", o.ORDER_ID as "Order ID", O.ORDER_DATE as "Date Ordered", s.SHIP_DATE as "Date Shipped", (s.SHIP_DATE-O.ORDER_DATE) as "Lag Time" FROM BILLING_DB.ORDERS o, BILLING_DB.SHIPPING s WHERE o.ORDER_ID = s.SHIP_ORDER_ID AND o.ORDER_ID = 4043
Repository Order ID Date Ordered Date Shipped Lag Time
BILLING 4043 12/01/2008 00:00:00 12/01/2008 00:00:00 0
BILLING 4043 12/01/2008 00:00:00 12/02/2008 00:00:00 1
But I only want it to return the first occurrence (the first time the order was placed/shipped).
Repository Order ID Date Ordered Date Shipped Lag Time
BILLING 4043 12/01/2008 00:00:00 12/01/2008 00:00:00 0
I tried using min(s.SHIP_DATE ) but that still returned the same result set.
Any help is very appreciated.
Thanks.
Comment