ยท Documentation ยท 1 min read
Pipe Syntax in SQL
How Google SQL's pipe syntax can be used to create a more readable query.

Recently, Google added pipe data flow syntax (|>
) to SQL.
SQL Example Query ๐
-- SQL Query
SELECT product_id, COUNT(*)
FROM orders_table
WHERE
sales_rep.email = 'rep@example.com'
AND order_status IN ('PENDING', 'CONFIRMED', 'SHIPPED')
GROUP BY product_id
ORDER BY product_id DESC;
Pipe Query Alternative ๐
FROM orders_table
|> WHERE
sales_rep.email = 'rep@example.com'
AND order_status IN ('PENDING', 'CONFIRMED', 'SHIPPED')
|> AGGREGATE COUNT(*)
GROUP AND ORDER BY product_id DESC;
Actually I really like using pipe syntax in sql, because now with pipe syntax the syntax order matches with the semantic evaluation order (query processing order) for SELECT
statement.
Share: