Data Lake • Write your own SQL

Stack two results

Can I put two answers in one list?

Try this

  • Run this on my data lake: SELECT 'orders' AS what, COUNT(*) AS rows FROM samples.shop_orders UNION ALL SELECT 'tickets', COUNT(*) FROM samples.shop_tickets ORDER BY what

In plain words

What is it?

One result goes on top of the other.

How does it work?

UNION ALL joins the two lists end to end. Both need the same number of columns, of matching kinds.

Good to know

Plain UNION also removes repeats. Load shop_tickets too for this one.