Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for cummulative table generation #230

Open
alexgawrilow opened this issue Dec 31, 2024 · 1 comment
Open

Suggestion for cummulative table generation #230

alexgawrilow opened this issue Dec 31, 2024 · 1 comment

Comments

@alexgawrilow
Copy link

When populating a cummulative table one year at a time, you can do it in a for-loop instead of changing the last year and this year by hand. Just a small suggestion to use this in the course.

DO $$
DECLARE
    start_year INT;
    end_year INT;
    this_year INT;
BEGIN
    SELECT MIN(year), MAX(year)
    INTO start_year, end_year
    FROM actor_films;

    FOR this_year IN start_year..end_year LOOP
        RAISE NOTICE 'Processing year: %', this_year;
        INSERT INTO actors
        -- >>>>> Your cummulative table generation query using the variable 'this_year' goes here <<<<<
    END LOOP;
END $$;
@isangwanrahul
Copy link
Contributor

There is code present in first-week folder under /sql which can populate multiple years of data in one run.
bootcamp/materials/1-dimensional-data-modeling/sql/load_players_table_day2.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants