As a CRUD developer one of the trade offs that needs to be made is the decision of how much of the work should be done in SQL on the server, and how much ought to be done on the client end in code.
How do you decide where the fulcrum goes? What factors go into your decisions? What kind of mistakes have you made? What works well?
[EDIT] I am kind of surprised in the low volume of responses to this question. I think this is a basic issue for all CRUD programming. Where the balance is set is a trade off between performance and maintainability.
The other issue I didn't really consider is the fact that the domains vary enough, that the answers probably need to be expressed in sections for each domain. That's kind of what I tried to do in my answer.
My priorities:
Minimize database trips. The code should do most of the work, if possible, and only visit the database when it has to. When it does, it should get as much needed for the current operation as possible.
Minimize SQL complexity. Even if we should visit the database less, this doesn't mean building an overly complex SQL query that is non-performant and does too much. The query will still need to be maintained, and if two simpler queries will save the headache of developing and maintaining one mega-query, then extra code should be used rather than more database work.
Minimize code list iteration. Code is great. A nice place to put the business logic, and lots of neat library functions. Code is awesome. But if using code means having to iterate over and over again through lists returned from the database where some simple database where clauses or joins could have eliminated that work, then the SQL needs to be improved, and the code minimized.
It's generally a case by case basis. For long-lived applications, maintenance is a huge cost and simplicity will often dictate my design.