I have a database table which contains a column that records page hits for every entry.
I want to select the top 5 most hit pages from the database, but can't seem to find the right method to do so using just SQL. In particular I'm looking for one which doesn't involve selecting every entry and scanning through it afterwards using PHP.
What's the best way to do this via SQL (if there is one)?
Thanks.
Try this approach:
SELECT column1, column2, hit_pages,...
FROM YourTable
ORDER BY hit_pages DESC
LIMIT 5
In MySQL> SELECT * FROM table ORDER BY hits DESC limit 5;
In Oralce> SELECT * FROM table ORDER BY hits DESC where rownum <5;
SELECT TOP 10 price(column Name) from products(tablename) order by price desc;
Below is the output
price 263.5 123.79 97 81 62.5 55 53 49.3 46 45.6
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