Week3 - Aggregate Functions / Assess

The questions can come in any order, so make sure you are selecting right option for all questions.

1. Write a query to display the number of travel cards having balance less than 45 from travel_card table. Give an alias name as min_balance_count.
select count(id) as min_balance_count from travel_card where balance<45;
2. Write a query to display the number of travel cards having balance greater than or equal to 45. Give an alias name as max_balance_count.
select count(id) as max_balance_count from travel_card where balance >= 45;
3. Write a query to display the variance of balance from the travel_card table. Give an alias name as balance_variance.
select variance(balance) as balance_variance from travel_card;
4. Write a query to display the sum of amount from the travel_payment table. Give an alias name as total_payment.
select sum(amount) as total_payment from travel_payment;

Post a Comment