able1: user_info = user_id, user_scubscription_type(trial/paid) table1 user_id = primary key table2 user_id = foreign key objective: To identify the 3rd highest feature is being used by trial users
table2: feature_usage = feature_id, user_id,
Apart from using limit what's the other way of writing query
I think we can even use row number function rt
Can anyone help me with the query

Rajanikant HawaldarRank #110 · 20.2K reputationPosted Sep 23, 2022, 8:40 AM EDT
Hello Amit,
If you start with...
select count(1), feature_id,user_id from table2 group by feature_id,user_id order by count(1) desc;That starts by giving you the most common features by user. But it FAILS to give you what you want. Because the numbers should all be 1!
Then you reailze what you want is:
Select count(1), feature_ID from feature_usage where user_id in (SELECT user_id from user_table where user_subscr=TRIAL) Order by 1;basically SUM up the features used by trial users.
Very important when dealing with sets is getting it straight in your head. Are you getting users or data for a set of users.
The second query gives you data (count of each feature) for a set of TRIAL users.
After this is working, you can add a WINDOWING function to get the "#". Using limits only after the data is sorted.