Skip to main content
Pardon the messYou are viewing docs related to an older version of Sequin. We’re in the process of updating our provider-specific guides and will be done in a few weeks (May 2024). Please click here to view the latest version of the docs.If you’re interested in Airtable and want to learn more about what’s changing, send us a note.

Tips

Examples

To play along with these example, you can setup a Sequin database connected to the Airtable Inventory Tracker template.

CAST

Airtable Formulas and Lookup Values can be numbers, strings, dates, or timestamps. So these fields are stored in your Postgres database as text and text[] columns, respectively. Let’s say you want to calculate your total revenue using SQL. Yo do so, you’ll sum up the total_price for all the purchase orders. Since total price is a formula in Airtable, we record it as type text in your Sequin database. So to calculate your total revenue, you’ll need to cast the total_price as an integer:
The :: casts the total_price column to an integer to then calculate the sum. Answer: Total revenue is \$17,280.

JOIN with ANY

A JOIN will let you use your Airtable data in new ways. For example, let’s say you want to use your warehouse space better. It would be helpful to see how many products are on each shelf in your warehouse. To do so, you can JOIN the warehouse_locations table with the product_inventory table and calculate the total inventory of all the products on each specific shelf:
Note the use of ANY. When performing the JOIN, there are many products associated with each warehouse location. These values are stored in an array. With ANY, you can JOIN on each value in the array. Join results Answer: The results are clear: shelf 3 is doing all the work :)

UNION

You’d like to send your design team all your product images scattered across your product inventory and your purchase orders. To do so, you need to do a UNION of the product_inventory table and the purchase_orders table:
Union results Answer: Your list of 42 images is ready in 70ms. (Now imagine getting that answer in Airtable…) Hopefully this cheat sheet of PostgreSQL helps you unlock your data. If not, search on Google - SQL is very well documented - or send us a note