You need to sign in to do that
Don't have an account?
Need Query for the below situation
Hi all,
I got a question in interview like.. you have a list with 100 records how will you get records from 25 to 75 from that list?
Somehow I have wrote a code like,
Thanks
I got a question in interview like.. you have a list with 100 records how will you get records from 25 to 75 from that list?
Somehow I have wrote a code like,
trigger GetRecs on Opportunity (before insert,before update) { list<Opportunity> opps = new list<Opportunity>(); list<Opportunity> opx = new list<Opportunity>(); opps=[select id,name from Opportunity where name!=null ORDER BY Name ASC LIMIT 100]; //opx=[select id,name from Opportunity where ] map<integer,opportunity> mapx=new map<integer,opportunity>(); for(integer i=0;i<101;i++) { mapx.put(i,opps[i]); } for(integer i=25; i<=76;i++) { if(mapx.containsKey (i)==true) { list<Opportunity> os=new list<Opportunity>(); os.add(mapx.get(i)); system.debug('recs'+opps[i]); } } }What is the mistake here?
Thanks
Query sample will be something line this
Do let me know if that answers your question.
Thanks,
Ray
For details you can visit the following link :
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_offset.htm
For your case SOQL will be like this :
Please mark this as answer if it solved your problem.
Thanks
Vikash Goyal