Given the database…..
ID Name item_order Manager
1 ted 2 N
2 bob 5 N
3 tony 1 Y
4 fred 3 N
5 william 4 N
6 george 6 Y
7 cade 8 N
8 matt 7 N
I would like to be able to select managers Id prior to the current non managers name. So for example the result for bob would be tony or 3.
I can figure out how to do this with two requests
SELECT MAX( item_order) AS parent
FROM tablename WHERE item_order < 5 && Manager = 'Y'
The result from that I would make another select by the item_order. Is there a way to do this all in one select?
1 Answer