Is this SQL query even possible in Drupal 7?
Drupal has it's own abstraction layer to work with database , this method helps Drupal to work with different kind of databases like PgSQL or even oracle (just a database driver will handle everything).

You can get familiar with this api in : Drupal Database API

A more exclusive reference could be : Drupal Dynamic Queries