I have a Products table, with a unique column named 'code'. The code starts with a letter, and then has subsequent numbers. So, product codes are like this: A01, A02, A03, A04, B01, B02, C01, C02, C03, and so on...
How can I get the highest number for each letter? (ie the current counter for A which would be 04, for B which is 02, for C which is 03, etc)
If your data have constant value? If yes, you can use MAX with GROUP BY LEFT(col,1)
example : SELECT MAX(RIGHT(col,2) FROM table GROUP BY LEFT(col,1)
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.