Use PASSING with JSON_TABLE() To Make Calculations
I ran across this trick while preparing a talk for the Southern California Linux Expo (SCaLE) on using JSON_TABLE(). This is a 'reserve' talk, which means it will presented IF another speaker drops out. But I thought this was interesting enough to share here. I will make sure the slides are posted online when finished. Passing Interest JSON_TABLE() temporarily converts JSON data into a relational table so that the temporary table can be processed by Structured Query Langauge (SQL) Commands. A feature in the PostgreSQL implementation is the passing clause. In the example below, you will see PASSING 1500 AS price_limit in red. This declares price_limit as a variable and assigns a value of 1500 to it. Later, in the body of the JSON_TABLE() call, you will see in green is_too_expensive BOOLEAN EXISTS PATH '$.price ? (@ > $price_limit)' . Here a variable is created named is_too_expensive of type BOOLEAN, which means we get a true or false answer from the r...