I tried to solve this query by
select * from (select u.user_id,u.email_id,u.password,u.first_name,u.last_name,u.city,u.gender,
u.phone_no from user_details u inner join ride_users r on u.user_id=r.user_id
group by u.user_id,u.email_id,u.password,u.first_name,u.last_name,u.city,u.gender,u.phone_no
order by count(r.ride_id) desc) where rownum<4;
but it didn't match the test case.
Can anybody help me?


Well, you need to find the USER_IDs of the top 3 ride getters. And each ride has its own RIDE_ID, so you have something to count. You want to get the count of rides for each user, and that will be something like:
and that will give you the top 3 users (assuming that there are no ties, and you haven't said what to do if there are, or what your database engine is, or given sample data or any of the things that are listed in this very helpful post: Why should I provide a Minimal Reproducible Example for a very simple SQL query?. Since I don't have any directions on what to do with edge cases, I'm just going to address the simplest general case, which is just taking the top 3 users).
Now, I see your desired output consists of rows from CARPOOLING.USER_DETAILS. So either you use IN and put your first query inside the parentheses, like this:
except IN needs to have only one field returned from the subquery, or it will give you an operand error, so omit the count in the select part of the subquery, and just use it in the order by clause:
or you can use a join instead of a subquery and only specify the records from USER_DETAILS:
Now, I haven't gone to the trouble to generate any sample data to test these against, so I'm really just whiteboarding. These queries aren't tested, but those are the general ideas. If you edit your question to include some sample data, perhaps even including a fiddle, and define what to do in cases where there are ties, I'll go back and edit my answer to address a real implementation.