In a different scenario, let's consider a table named transactions that contains comprehensive details about rides and deliveries, with individual rows for each type of transaction. This table includes the fields zip_code , transaction_type (which can be either ride or delivery), and completed_transactions . SELECT zip_code , SUM ( CASE WHEN transaction_type = 'ride' THEN completed_transactions END ) AS total_rides , SUM ( CASE WHEN transaction_type = 'delivery' THEN completed_transactions END ) AS total_deliveries FROM transactions GROUP BY zip_code ; This SQL query performs the following tasks: It calculates the sum of 'completed_transactions' where 'transaction_type' is 'ride', and labels this sum as 'total_rides'. It calculates the sum of 'completed_transactions' where 'transaction_type' is 'delivery', and labels this sum as 'total_deliveries'. These calculations will be done for each distinct 'zip_code', providing the total number of rides and deliveries completed within each zip code.