Date: Tue, 8 Jul 2008 12:09:03 -0700 (PDT)
I'm trying to use an analytic function to get the first row in a group ordered by a date.
SELECT customer_id, action,
OVER (PARTITION BY customer_id
ORDER BY action_date DESC) AS LAST_DATE
ORDER BY customer_id;
Customer ID Action Action Date
413 D 29-AUG-07 413 D 29-AUG-07 416 D 09-SEP-06 416 D 09-SEP-06 416 A 09-SEP-06 416 D 09-SEP-06 416 A 09-SEP-06 416 D 09-SEP-06 421 D 15-APR-08 443 D 04-MAY-04
Now, I have truncated the date, so the minutes should not matter. But, because I use FIRST_VALUE and I am partitioning on the customer ID, I thought it would basically group it by customer ID and then get the first record, as the group is ordered by date DESC.
But, I am getting duplicated, which I should not be. Anyone see what is wrong with my query?
John. Received on Tue Jul 08 2008 - 14:09:03 CDT