Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table jon.vins (vin citext primary key);
- insert into jon.vins values
- ('3GNAXUEV1KL221776'),
- ('3GNAXHEV2KS548975');
- CREATE TABLE jon.describe_vehicle (
- vin citext primary key,
- response jsonb);
- select a.vin,
- b.response->'attributes'->>'bestMakeName' as make
- from jon.vins a
- left join jon.describe_vehicle b on a.vin = b.vin;
- vin | make
- -------------------+-----------
- 3GNAXUEV1KL221776 |
- 3GNAXHEV2KS548975 | Chevrolet
- (2 rows)
- select a.vin,
- jsonb_array_elements(b.response->'style')->'attributes'->>'name' as style
- from jon.vins a
- left join jon.describe_vehicle b on a.vin = b.vin;
- vin | style
- -------------------+------------------
- 3GNAXHEV2KS548975 | FWD 4dr LS w/1LS
- (1 row)
Add Comment
Please, Sign In to add comment