Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Return the total number of apps in the table fake_apps */
- SELECT MAX(id) FROM fake_apps ;
- /*Return the name, category, and price of the app that has been downloaded the least amount of times. */
- SELECT name, category , MIN(downloads)
- FROM fake_apps;
- /*Return the total number of apps for each category */
- SELECT category, SUM(downloads)
- FROM fake_apps
- GROUP BY category;
- /*Return the name and category of the app that has been downloaded the most amount of times */
- SELECT name, category FROM fake_apps
- WHERE downloads = (SELECT MAX(downloads) FROM fake_apps);
- /*Return the name and category of the app that has been fownloaded the least ammount of times */
- SELECT name , category FROM fake_apps
- WHERE downloads = (SELECT MIN(downloads)
- FROM fake_apps);
- /* Return the average price for an app in each category */
- SELECT AVG(price) FROM fake_apps
- GROUP BY category;
- /*Return the average price for an app on each category. Roun the averages to two decimal places */
- SELECT ROUND(AVG(price) ) FROM fake_apps
- GROUP BY category;
- /*Return the maximum price for an app */
- SELECT MAX(price) FROM fake_apps;
- /*Return the minimum number of downloads for an app */
- SELECT MIN(downloads) FROM fake_apps;
- /*Return the total number of apps that are free */
- SELECT COUNT(name) FROM fake_apps
- WHERE price = 0;
- /*Return the total number of apps that cost
- 14.99*/
- SELECT COUNT(name) FROM fake_apps
- WHERE price = 14.99;
- /*Return the sum of the total number of downloads for apps that belong to the music category*/
- SELECT SUM(downloads) FROM fake_apps
- WHERE category = 'Music';
- /*Return the sum of the total numver of downloads for apps that belong to the Business category */
- SELECT SUM(downloads) FROM fake_apps
- WHERE category ='Business';
- /*Return the price and average number of downloads grouped by price */
- SELECT category, SUM(downloads)
- FROM fake_apps
- GROUP BY category;
- /* Return thep price and average number of downloads grouped by price. Round the averages to the nearest integer. */
- SELECT price , ROUND(AVG(downloads)) FROM fake_apps
- GROUP BY price;
- /*Return the name and category and price of the most expensive app for each category */
- SELECT name, category, MAX(price)
- FROM fake_apps;
- /*Return the totalt number of apps whose name begin with the letter 'A'*/
- SELECT COUNT(name) FROM fake_apps
- WHERE name LIKE '%A';
- /*Return the total number of downloads for apps belonging to the Sports or Health & Fitness category */
- SELECT SUM(downloads) FROM fake_apps
- WHERE category = 'Sports'
- OR
- category = 'Health & Fitness category';
Advertisement
Add Comment
Please, Sign In to add comment