substring and cast in esq

I have column in object called "Lead no" in format- "L_". I want to get the maximum value of integer value in the same through esq.

SQL query of something like this:

SELECT MAX(CAST(SUBSTRING("UsrName",3,length("UsrName")) AS DECIMAL)) FROM "UsrLead"

can someone help me on this?



Like 0



Hi Gokul, 


Here are some examples how you can implement it : 


1. By using direct SQL queries…


2. By using "Select" class…


3. By using client side logic (but modifying this code according to your business logic) example below


var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Activity" });
esq.addColumn("Account.UsrINN", "AccountINN");
var column = esq.addColumn("ModifiedOn");
column.orderDirection = Terrasoft.OrderDirection.ASC; 
esq.filters.addItem(esq.createColumnFilterWithParameter(3, "Account.UsrINN", "7730616959")); 
esq.getEntityCollection(function (result) {
    if (result.success && result.collection.getCount() > 0) {
        var item = result.collection.getByIndex(0);
        var INN = item.get("AccountINN");
        var modOn = item.get("ModifiedOn");
}, this);



P.S. Please refer the post below about ESQ access rights, that could be also useful for you



Show all comments