Skip to content
Advertisement

How to order the query result based on following condition?

Let’s suppose I have a table as below:

this data shows the commission earned by employees based on time period. now, I need to get the data in the following format in node.js code

I have written following query

This query gave me the desired result, but now I also want to sort the employees based on commission earned in a specific period e.g. sort employees based on the commission earned in period=’1Y’. I am unable to find a solution with this query. Please provide any other good solution for these kinds of problems

Advertisement

Answer

Extract the one year commission in your query and use it in the wrapper query to sort the results:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement