If I have the table “members” (shown below), how would I go about getting the record of the first occurrence of a membership_id (Oracle).
Expected results
123 John Doe A P
313 Michael Casey A A
113 Luke Skywalker A P
Table – members
membership_id first_name last_name status type
123 John Doe A P
313 Michael Casey A A
113 Luke Skywalker A P
123 Bob Dole A A
313 Lucas Smith A A
will work for your sample data set. If you can have ties– that is, multiple rows with the same
membership_idand the same maximumtype— this query will return all those rows. If you only want to return one of the rows where there is a tie, you would either need to add additional criteria to theorder byto ensure that all ties are broken or you would need to use therow_numberfunction rather thanrankwhich will arbitrarily break ties.