Datastar_Meetup/material/sqlite/countries_csv.sql
2025-11-11 06:33:53 +01:00

19 lines
458 B
SQL

.mode csv
.headers on
.output countries.csv
WITH raw AS (
SELECT
value AS country
FROM json_each(readfile('countries.json'))
)
SELECT
json_extract(country, '$.translations.deu.common') AS german_name,
json_extract(country, '$.population') AS population,
json_extract(country, '$.capital[0]') AS capital,
json_extract(country, '$.timezones') AS timezones
FROM raw
ORDER BY german_name;
.output stdout