You need to sign in to do that
Don't have an account?
cwood
Implicit ORDER BY for SOQL queries?
If I specify a batch size of 25 and then perform a query like "SELECT FirstName, LastName from contact", will I get the 25 most recently created contacts?
If not, which contacts will I get? And if not, how can I query for the 25 most recently created contacts?
Thanks,
Charlie
If not, which contacts will I get? And if not, how can I query for the 25 most recently created contacts?
Thanks,
Charlie
Message Edited by cwood on 04-05-2006 10:17 AM
Message Edited by cwood on 04-05-2006 10:17 AM
SELECT FirstName, LastName FROM contacts WHERE CreatedDate > (7 days ago)
then checking to see that at least 25 were returned. If fewer than 25 were returned, we expand the date range and do a query like
SELECT FirstName, LastName FROM contacts WHERE CreatedDate > (14 days ago)
looping until we get >= 25 results. Once we have at least 25 results, we sort the returned objects on CreatedDate, and then use the 25 most recent.
Does that sound right? If so, I can't wait for ORDER BY. :-)
-Charlie
One thing to note with that solution. There may be a point at which doing a larger query, including the CreatedDate, and then sorting the results if > 25 may be faster then stepping up thru multiple queries. Depending on your usage you may want to find a query that returns ~100 records or so and sort them to get your 25.
Thanks,
Charlie
I am waiting with great antici...
...pation. :)
Thanks