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

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.