I have a table which contains invoice and estimate numbers.The invoice numbers are like "IN1000","IN1001","IN1002"
and so on.The estimate numbers are like "ES101","ES102","ES103"
.How can I get the max of both my invoice and estimate? I would also like it to be cast into an integer like 1000.
I have tried the following query:
SELECT Max(CAST (SUBSTR(invoiceNo,3) AS UNSIGNED)) FROM selected_items
WHERE invoiceNo RLIKE 'IN';
When I run this query I get the following error :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNSIGNED)) FROM selected_items WHERE invoiceNo RLIKE 'IN'' at line 1.
And I am using similar approach for estimate :
SELECT Max(CAST (SUBSTR(invoiceNo,3) AS UNSIGNED)) FROM selected_items
WHERE invoiceNo RLIKE 'ES';
How can I do both the operations in one query? Any help is appreciated.Thank you.