It depends. Generally, you should let the database do things databases are good at - filtering, sorting, and joining data. Complex post-query transformations of data (business logic) you should generally be doing in your application code, and not in the query, especially since debugging these things can really be awful in SQL, but relatively pain-free in application code.
If you are fully confident that your datasets are always going to be very small (let's say... less than a few hundred records) and your manipulations always rather simple, then doing your manipulations in your application code rather than SQL will probably make no difference in overall performance or maintainability.
On the other hand, if you datasets have the possibility of growing very large some day (you should definitely test this out - fill your tables with dummy data to test this!) then you run the risk of writing application code that is unbearably clunky and probably uses monster amounts of memory to do things that the database would be much better doing for you. At this point you might need to look into what manipulations the database can do more efficiently versus the application code, and divide the workload up as appropriately as possible. Doing so would require testing and analysis on your part of both the data and the manipulations you're working with.
The final answer? Decide based on your needs how to appropriately split up the work that can be done effectively by the database server (in SQL) and can be done efficiently and cleanly in your application code.