Dev Helpers
← Back

Compare numeric values for matching keys

Compare numeric values for matching keys using SQLite JSON functions.

Open this example in the interactive library

Source code

SELECT a.key,b.value-a.value AS delta FROM json_each('{"north":4,"west":9}') a JOIN json_each('{"north":7,"west":6}') b USING(key) ORDER BY a.key;

Sample output

[
  {
    "key": "north",
    "delta": 3
  },
  {
    "key": "west",
    "delta": -3
  }
]