It depends. Generally, you should let the database do what the databases are good at filtering, sorting, and combining data. Comprehensive post-query data transformations (business logic), which you usually need to perform in the application code, and not in the request, especially since debugging these things can be terrible in SQL, but relatively painless in the application code.
, (... ), , , SQL, , .
, - ( ), , !), , , , , , . , , . , , .
? , , , ( SQL), .