【发布时间】:2019-07-19 02:22:02
【问题描述】:
我有两张这样的桌子:
product_table[ product_id, product_name,original_store_id, destination_store id]
和
store_table[ store_id, establishment_date, location]
我要查找的是:从所有那些发货到没有成立日期的商店的产品中,有多少是从有成立日期的商店发货的?
这是我的查询:
SELECT count(a.product_id) as count_of_products
FROM product_table a
JOIN store_table b
ON a.original_store_id = b.store_id AND a.destination_store_id = b.store_id
WHERE b.establishment_date IS NULL
我知道这应该是一个嵌套查询,但是如何将它们放在这里?
【问题讨论】:
标签: mysql sql google-bigquery