diff --git a/chocolatey/README.md b/chocolatey/README.md index e5e10379..dc76a274 100644 --- a/chocolatey/README.md +++ b/chocolatey/README.md @@ -6,6 +6,7 @@ sql-cli to the [Chocolatey Community Repository](https://community.chocolatey.or ## Layout - `sql-cli.nuspec.template` — package metadata. `__VERSION__` is replaced at pack time. + `iconUrl` must stay on `cdn.jsdelivr.net`: moderation rejects `raw.githubusercontent.com`. - `tools/chocolateyInstall.ps1.template` — downloads the Windows binary from the matching GitHub release and verifies its SHA256. `__VERSION__` and `__CHECKSUM__` are replaced at pack time. diff --git a/chocolatey/sql-cli.nuspec.template b/chocolatey/sql-cli.nuspec.template index e1f4500f..e1f90212 100644 --- a/chocolatey/sql-cli.nuspec.template +++ b/chocolatey/sql-cli.nuspec.template @@ -12,7 +12,7 @@ https://github.com/TimelordUK/sql-cli/blob/main/README.md https://github.com/TimelordUK/sql-cli/issues https://github.com/TimelordUK/sql-cli/blob/main/LICENSE - https://raw.githubusercontent.com/TimelordUK/sql-cli/v__VERSION__/assets/icon.png + https://cdn.jsdelivr.net/gh/TimelordUK/sql-cli@v__VERSION__/assets/icon.png false Vim-like terminal SQL editor and engine for CSV / JSON / JSONL data. diff --git a/examples/countries.sql b/examples/countries.sql index c0434bd6..b35017ef 100644 --- a/examples/countries.sql +++ b/examples/countries.sql @@ -29,6 +29,39 @@ FROM #countries WHERE "name.common" = 'Russia'; go +-- using unnest to explode the borders on left hand side to self join back to get the matching row on right + +WITH + all AS ( + SELECT + "name.common" as name, + cca3, + latlng, + borders, + area + FROM #countries + ), + lc AS ( + SELECT + l.name as l_name, + l.cca3 AS iso, + l.latlng, + l.borders, + SPLIT_PART(l.latlng, ',', 1) AS lat, + SPLIT_PART(l.latlng, ',', 2) AS lon, + l.area, + Unnest(l.borders, ',' ) AS border + FROM all + WHERE l.cca3 = 'BRA' + ) +SELECT + lc.*, + r.latlng, + r.name as r_name +FROM lc +INNER JOIN all AS r ON l.border = r.cca3 +GO + SELECT "name.common" as name, region, cca3 as iso,