I have a database I'm working on and I'm trying to figure out how to return every row that has the highest number in a specific column.
SELECT * MAX(version_group_id) = max_version_group_id
FROM table
GROUP BY max_version_group_id
ORDER BY max_version_group_id DESC;`;
I keep getting syntax errors and can't find out what is wrong here. I'm fairly new to sql.
The question is not clear. If you want to select the rows whos column value is equal to the the highest column value of the table, use the following query:
SELECT *
FROM table
WHERE version_group_id = (
SELECT MAX(version_group_id)
FROM table
)
It has a subquery that finds out which value is the highest.
The correct select syntax you try to implement is:
SELECT *, MAX(version_group_id) AS max_version_group_id
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.