Displaying hierarchical content is a common request of database-driven web sites. Drupal gives you great flexibility in doing this without writing a single line of code, using a couple of battle-tested modules.
We use the Views UI a lot to create custom pages, blocks, etc. Sometimes it does not give us exactly what we want and we would like to modify the generated sql query. It's possible to achieve this through the 'views_query_alter' hook.
using the term "content management system" to describe the drupal cms understates it's full potential. i prefer to consider drupal a web-application development-system, particularly suitable for content-heavy projects.