Week 136 - SQL & Query Techniques
Hey hey hey!
Spring has finally arrived, and we want to celebrate it 🌸Each gardener has carefully prepared their own seed packs — arrays of seed counts (in grams) for different flower types. Your job is to help them compute the total weight of their custom mixes. 🌼
Instead of summing manually or unpacking arrays one by one, you're going to use Snowflake's spread operator to pass array values directly into a function🌿
-- Setup Script
Step 1: Create the seeds table 🌸🌿
CREATE OR REPLACE TABLE seed_packs (
gardener STRING,
seeds ARRAY
);
Step 2: Insert your spring options 🌼🌼
INSERT INTO seed_packs
SELECT 'Luna', ARRAY_CONSTRUCT(5, 10, 15)
UNION ALL
SELECT 'Sol', ARRAY_CONSTRUCT(7, 8, 9)
UNION ALL
SELECT 'Anna', ARRAY_CONSTRUCT(4, 12, 18)
UNION ALL
SELECT 'Daniel', ARRAY_CONSTRUCT(6, 8, 2);