Guest User

Untitled

a guest
Nov 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. create table jon.vins (vin citext primary key);
  2. insert into jon.vins values
  3. ('3GNAXUEV1KL221776'),
  4. ('3GNAXHEV2KS548975');
  5.  
  6. CREATE TABLE jon.describe_vehicle (
  7. vin citext primary key,
  8. response jsonb);
  9.  
  10. select a.vin,
  11. b.response->'attributes'->>'bestMakeName' as make
  12. from jon.vins a
  13. left join jon.describe_vehicle b on a.vin = b.vin;
  14.  
  15. vin | make
  16. -------------------+-----------
  17. 3GNAXUEV1KL221776 |
  18. 3GNAXHEV2KS548975 | Chevrolet
  19. (2 rows)
  20.  
  21. select a.vin,
  22. jsonb_array_elements(b.response->'style')->'attributes'->>'name' as style
  23. from jon.vins a
  24. left join jon.describe_vehicle b on a.vin = b.vin;
  25.  
  26. vin | style
  27. -------------------+------------------
  28. 3GNAXHEV2KS548975 | FWD 4dr LS w/1LS
  29. (1 row)
Add Comment
Please, Sign In to add comment