How do I write a simple SELECT statment which limits the report to only the top 5 of a column value?
You'd have to sort by that column value, maybe in descending order, depending on what you mean by "top 5" ; and fetching only the 5 top lines.
Using MySQL, you'd have something like this, I'd say :
select *
from your_table
where ...
order by your_column desc
limit 5
Using MSSQL server, you don't have limit
, but you could use top
:
select top 5 *
from your_table
where ...
order by your_column desc
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