You need to sign in to do that
Don't have an account?
sarvesh001
Soql Query
Hi,
I am quering the custom objects records based on ownerid and logindate field. Now i want to query the record based on order by ownerid and order by loginate field.
My requirement is i want to get the records for every user in ASC order of records for every user.
Can any one help me....
Thanks,
Sarvesh.
I am quering the custom objects records based on ownerid and logindate field. Now i want to query the record based on order by ownerid and order by loginate field.
My requirement is i want to get the records for every user in ASC order of records for every user.
Can any one help me....
Thanks,
Sarvesh.
As you said, you want to sort the query using two fields, you can follow the query below. Let me know if that doesnt helps you
All Answers
It is fairly simple to implement ORDER BY in a SOQL. Conside the following example without SOQL and with SOQL :
Without ORDER BY:
With ORDER BY:
This is all my understanding of your question. If you have a different requirement, please elaborate.
I have used the above query
SELECT OwnerId, LoginDate__c FROM <customObject> where OwnerId = 'xxxxx' AND LoginDate = 'xxxxx' ORDER BY OwnerId ASC
In this query query recodrs like 1st record of 1st user then 1st record of 2nd user then 2nd record of 1st user then 2nd record of 2nd user ..................................
But i want to get records like 1st record of 1st user then 2nd record of 1st user ...........then 1st record of 2nd user then 2nd record of 2nd user..................
Can you please the same query. Because, you should not be getting the result as you suggested. The result should always have all the records of first user and then all the records of second user. The query is correct. Can you please check the data again.
As you said, you want to sort the query using two fields, you can follow the query below. Let me know if that doesnt helps you
isuue is sloved.
i have used the query SELECT OwnerId, LoginDate__c FROM <customObject> where OwnerId = 'xxxxx' AND LoginDate = 'xxxxx' ORDER BY OwnerId ,LoginDate ASC