3 ms·
>what if we want to return the salary too? >the only solution is to change half of the lines in the query How about adding a second subquery for the salary.
by croes 5y ago
>what if we want to return the salary too?
>the only solution is to change half of the lines in the query
How about adding a second subquery for the salary.
- gerbler 5y agoThis example seemed wrong to me as well. You can have a subquery, or CTE that returns as many fields as you want and can join on the manager key
- kinjba11 5y agoAn additional subquery and a CTE are both restructuring the query significantly, which is the author's point.
- pjmlp 5y agoWell if he is insisting in doing the SQL version of writing everything inside a lambda without modularizing the code, then yeah that is bound to happen.
- gerbler 5y agoThere's already a subquery in there. I'm saying this can still be done with one subquery, just in a different place and it returns the desired results.
- kinjba11 5y agoIt is a toy example. Perhaps imagine a more realistic subquery that is much longer. Are you going to duplicate a 50 line subquery to get the salary when all you want is one more value? No, you'd probably want to restructure the query with a join or CTE instead. To the author's point, a large change relative to the gain.