One of the most asked query in the interview,
how to get top N record in hte each group
get 15th largest records from DB with out using limit
you can solve above problem statement using rank concept
create a new column in table it will rank your records , by using this rank you can resolve above problem
query and sample dataset you can get it from the aboe screenshot . and of course result set as well.
basic idea is , creare a session varibale which will increment the rank.
at the end get the result set based on the rank.
how to get top N record in hte each group
get 15th largest records from DB with out using limit
you can solve above problem statement using rank concept
create a new column in table it will rank your records , by using this rank you can resolve above problem
query and sample dataset you can get it from the aboe screenshot . and of course result set as well.
basic idea is , creare a session varibale which will increment the rank.
at the end get the result set based on the rank.
No comments:
Post a Comment