how to select the first maximum prices in a table without using the clause "where" ?
Asked
Active
Viewed 64 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 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 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 Apr 14 '19 at 10:26
4 Answers
1
In mysql -
SELECT * FROM table_name
ORDER BY price desc LIMIT 50;

Nick
- 138,499
- 22
- 57
- 95

Khilesh Chauhan
- 739
- 1
- 10
- 36
1
this will work in mysql:
SELECT
select_list
FROM
table_name
order by column_name
LIMIT 0 , 50;

Nikhil S
- 3,786
- 4
- 18
- 32
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,242,037
- 58
- 646
- 786