Query - Select the largest number in DB Column

Hi
I am new to this and just trying the AppSmith. So far so good, but sometimes have hard time finding examples or answers to my questions.

I like to know how do I select and retrieve the largest number from a database column (e.g. CL2 100034)
COL1 COL2
Ben 100020
Kev 100034
Sev 100015

What I am trying to do is, I have a column ID which is a number and I am adding another member to that database and like to have a unique but sequential ID based on the last ID number in the DB Table. " Largest Number In TBL + 1"

Thanks in advance

You should be able to use MAX SQL function to get the largest number.

E.g. - SELECT MAX(SALARY) FROM Employee;

This worked

{{
function(){
var data = get_clientlastid.data.map(o => o.client_id);
var lastid = Math.max(…data);
var newid = lastid + 1;
return newid;
}
()
}}