how to select the first maximum prices in a table without using the clause "where" ?
Asked
Active
Viewed 62 times
0
-
1`SELECT TOP 50 * FROM tab ORDER BY Prices DESC` - depending on RDBMS `TOP/LIMIT/OFFSET - FETCH` – Lukasz Szozda Apr 14 '19 at 10:10
-
thank you but u are using sql server in this case , i want it in mysql – Sara Stone Apr 14 '19 at 10:11
-
1I provided an answer already. Please read carefully. – Lukasz Szozda Apr 14 '19 at 10:12
-
thank you , sorry i've just seen it ^^ – Sara Stone Apr 14 '19 at 10:13
-
1here is the result in sql oracl too : https://stackoverflow.com/questions/470542/how-do-i-limit-the-number-of-rows-returned-by-an-oracle-query-after-ordering – Sara Stone Apr 14 '19 at 10:26
4 Answers
1
In mysql -
SELECT * FROM table_name
ORDER BY price desc LIMIT 50;
Nick
- 123,192
- 20
- 49
- 81
Khilesh Chauhan
- 547
- 5
- 24
1
this will work in mysql:
SELECT
select_list
FROM
table_name
order by column_name
LIMIT 0 , 50;
nikhil sugandh
- 3,422
- 4
- 16
- 29
0
Your question is unclear.
If you want 50 rows, even when there are duplicates, then you can use:
select price
from t
order by price desc
limit 50;
If you want 50 distinct prices, then you can use:
select distinct price
from t
order by price desc
limit 50;
Gordon Linoff
- 1,198,228
- 53
- 572
- 709