In a table containing cities I want to get the five biggest cities and order them by name:
SELECT * FROM cities ORDER BY population DESC LIMIT 5
That gets me the biggest cities ordered by population, but I want the same cities ordered by name. Is there an easy way to do this (without turning to a subquery or sorting the cities afterwards with PHP)?
Limit order This means that your order may only be filled at your designated price or better. However, you're also directing your order to fill only if this condition occurs. Limit orders allow control over the price of an execution, but they do not guarantee that the order will be executed immediately or even at all.
Market orders are transactions meant to execute as quickly as possible at the current market price. Limit orders set the maximum or minimum price at which you are willing to complete the transaction, whether it be a buy or sell.
A limit order is the use of a pre-specified price to buy or sell a security. For example, if a trader is looking to buy XYZ's stock but has a limit of $14.50, they will only buy the stock at a price of $14.50 or lower.
At-or-better orders are examples of limit orders. They are executed at a specific price or above. Limit orders take longer to execute and may not even be executed because of their specific price requirements. Placing an at-or-better order is looking for a breakout and wanting to participate in the next move upwards.
I think what you want is this:
( SELECT * FROM cities ORDER BY population DESC LIMIT 5 ) ORDER BY name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With