Skip to content

Instantly share code, notes, and snippets.

@sspaeti
Last active February 3, 2025 09:25
Show Gist options
  • Save sspaeti/64405c15ef5b0f969435195cbdd05c04 to your computer and use it in GitHub Desktop.
Save sspaeti/64405c15ef5b0f969435195cbdd05c04 to your computer and use it in GitHub Desktop.
This queries a shared DuckDB database on MotherDuck with StackOverflow Survey
--connect to MotherDuck databases
-- configure MOTHERDUCK_TOKEN and run DuckDB that connects to all shared Databases with
-- `duckdb "md:"`
-- and then run this query:
WITH language_counts AS (
SELECT
language,
COUNT(*) AS count
FROM (
SELECT UNNEST(STRING_SPLIT(LanguageHaveWorkedWith, ';')) AS language
FROM sample_data.stackoverflow_survey.survey_results
WHERE year='2024'
) AS languages
GROUP BY language
),
max_count AS (
SELECT MAX(count) as max_value
FROM language_counts
)
SELECT
language,
count,
bar(count, 0, max_count.max_value, 40) as chart
FROM language_counts, max_count
ORDER BY count DESC
LIMIT 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment