How would you write a SQL query to retrieve specific data from a database, possibly involving joins and aggregations?