I have a table Sales with the following fields: code, amount, index, name.
I need to get the smallest and the largest amount for a given name, and the code for which the amount is the smallest and largest.
Can somebody help me in constructing a query?
To find min and max amount per name:
and to get both(min and max) and code in single query: