in above table, i need to get the highest id of year 2020 sales.
i tried with below query, but the results seems not correct.
ORDER BY id DESC
The above query does not give 107 on top
SELECT MAX(id) AS highest_id
WHERE YEAR(sold_date) = 2020
sorry it did not work
and here see this query and resut
but problem is, same id column have move higest values than 99. see this pls
and finally table structure
Why is id a varchar? Sorting a varchar (for MAX) is Lexicographical, not numeric.
Thank you !!!
converted to int and resolved!!
Thank every one for the great support.
Thank you to r937. That Year function is an extra piece of knowledge for me!
YEAR() function still work as the OP stores the two dates in ‘text’ columns?
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.