how can i get calculate total sum of field based on grouping
like in sql select username,sum(filed1) form table group by username.
i have table like this
username field1
ram 3000
sai 1000
ram 6000
sai 5000
o/p:
ram 9000
sai 6000
Hi,
Please use the following query in the script component.
function callback(arr){
for(var i=0;i<arr.length;i++){
//Do Something with arr[i][0] and arr[i][1] (Since we have only two colums Username and Amount)
alert(arr[i][0]+":"+arr[i][1]);//arr[i][0] is Username and arr[i][1] is Sum of the amount
}
}
function process()
{
rbf_selectQuery("SELECT Username, SUM(Amount) FROM Object_A GROUP BY Username", 100, callback);
}
But ,instead of doing this you can still make use of view where you can apply filter logic on any field.
documentation.progress.com/.../index.html
Regards,
Shiva
hi shiva
i have 2 object 1.fuldata 2.limitshow
in fulldata object i have like this
name sal
ram 3000
ram 2222
sai 4444
sai 5555
ram 1111
i need to show in 2.limitshow
name sal
ram 7333
sai 9999
in every updation or new entry it(limitshow) shld be update from fulldata
Hi,
Create a trigger of type "Object Script" on FullDate Object. Use the below navigation for creating trigger.
FullDate->Object definition->Trigger->New Trigger->Select Object script.
Under the trigger configuration section include the following code.This will check if the record is already existed in LimitShow object with same name as FullData object.If record already exists then it will update the salary field,if record is not available then a new record is being created.
var isRecordExists=rbv_api.selectNumber("SELECT COUNT(1) FROM LimitShow WHERE name=?",'{!name#text}');
//Update if record in FullData already exists.Otherwise create a new record.
if(isRecordExists>0){
var id=rbv_api.selectNumber("SELECT id FROM LimitShow WHERE name=?",'{!name#text}');
var sumOfSal= rbv_api.selectNumber("SELECT SUM(Salaray) FROM FullData WHERE name=?",'{!name#text}');
rbv_api.updateRecord("LimitShow", id, {'Salary':sumOfSal});
}else
{
rbv_api.createRecord("LimitShow", {'name':'{!name#text}','Salary':{!Salaray}});
}
Attaching app.xml for your reference.
Please let me know in case you need any assistance.
Regards,
Shiva
[View:/cfs-file/__key/communityserver-discussions-components-files/25/3581.SampleApplication_5F00_v2.xml:320:240]
Thank you Shiva. Got it..