I have the following table:
Table Scores:
+----+-------+
| Id | value |
+----+-------+
| 1 | 300 |
| 2 | 300 |
| 3 | 300 |
| 4 | 100 |
| 5 | 200 |
+----+-------+
What I need as a result of the query:
+----+-------+
| Id | value |
+----+-------+
| 1 | 300 |
| 2 | 300 |
| 3 | 300 |
| 4 | 300 |
| 5 | 300 |
+----+-------+
With what query can I achieve this?
(this is just part of a complex query, this would help a lot to minimize my code)
You could cross join
the table with a query that returns the max value:
SELECT id, max_value
FROM scores
CROSS JOIN (SELECT MAX(value) AS max_value
FROM scores) m
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.