I have a SCORE column. How do I select the top 10% from EMPLOYEE table with top scores?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could do it with analytics. Assuming that score is ascending (higher scores are better):
This will select at most 10% of your employees. If there are equal scores among them, the above SQL will pick among them in a non-deterministic fashion. If you want to include all those that are in the top 10% including duplicate scores, replace
row_number()byrank().You could also use the
NTILEfunction: