pagesheetal
asked on
ORACLE SQL - to get the first_value and the last_value using OVER PARTITION BY
Hi Folks,
I have a table cnam_load which is Oracle table and the columns of the table are :-
mdn
action_type
I have to use the over partition by command to get the first value and the last value of the action_type and it should be grouped by mdn and count(*) > 1. I never used over partition by command and I am not sure how to build this query. I would appreciate your advice.
Thanks
I have a table cnam_load which is Oracle table and the columns of the table are :-
mdn
action_type
I have to use the over partition by command to get the first value and the last value of the action_type and it should be grouped by mdn and count(*) > 1. I never used over partition by command and I am not sure how to build this query. I would appreciate your advice.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select * from
(select mdn, first_value(action_type) over (partition by mdn order by action_type) first_action,
last_value(action_type) over(partition by mdn over action_type) last_action,
count(*) over (partition by mdn) cnt
from cnam_load
) where cnt > 1