Skip to content

Instantly share code, notes, and snippets.

@diazvictor
Created March 24, 2021 22:19
Show Gist options
  • Save diazvictor/a7d43d236c81059f9a8ecb3bc2a52903 to your computer and use it in GitHub Desktop.
Save diazvictor/a7d43d236c81059f9a8ecb3bc2a52903 to your computer and use it in GitHub Desktop.
SoloLearn | SQL | Cakes
/**!
* @package SoloLearn | Sql
* @filename cakes.sql
* @autor Díaz Urbaneja Víctor Eduardo Diex <victor.vector008@gmail.com>
* @date 24.03.2021 17:54:43 -04
*/
-- This is an exercise from the solorearn course:
-- https://www.sololearn.com/learning/1060/
-- =============================
-- = Exercise =
-- =============================
-- A local bakery creates unique cake sets. Each cake set contains three different
-- cakes. Here is the cakes table:
-- name calories
-- ------------ ----------
-- Apple Cake 100
-- Banana Cake 200
-- Pound Cake 180
-- Sponge Cake 100
-- Genoise Cake 360
-- Chiffon Cake 250
-- Opera Cake 90
-- Cheese Cake 370
drop table cakes;
create table cakes (
name varchar,
calories integer
);
insert into cakes ( name, calories ) values
("Apple Cake", 100),
("Banana Cake", 200),
("Pound Cake", 180),
("Sponge Cake", 100),
("Genoise Cake", 360),
("Chiffon Cake", 250),
("Opera Cake", 90),
("Cheese Cake", 370);
-- Тoday a customer want a cake set that has minimal calories. Write a query to
-- sort the cakes by calorie count and select the first 3 cakes from the list to
-- offer the customer.
-- Expected output
-- Opera Cake | 90
-- Apple Cake | 100
-- Sponge Cake | 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment