{"version":"1.0","type":"rich","title":"unpivot-postgres.sql","description":"This example reshapes two country-level datasets into a unified, chart-ready format for visualizing trends over time. It first pivots the CyberSecurityIndex table, converting three separate columns—National Cyber Security Index, Digital Development Level, and their difference—into a long-form structure using a `cross join lateral` with a `values` clause. It then appends rows from the PressFreedomIndex table, retaining its country, ISO code, year, and index value. The SQL uses `CAST` to normalize year and value types, ensuring consistent numeric and text formats across both sources before combining them with `UNION`.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-f1c4f5fa2e3056003a435451ccdcfdfb?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}