我有兩個表像SQL聚合調用
1)客戶
id | name
------+-------------------
1 | xyz1
2 | xyz2
3 | xyz3
4 | xyz4
5 | xyz5
2)產品
id | name | customer | state
------+-------------+----------+-------
1 | product 1 | 1 |Shipped
2 | product 2 | 1 |Pending
3 | product 3 | 1 |Shipped
4 | product 4 | 1 |Pending
5 | product 5 | 2 |Shipped
我想有一個查詢是這樣的:
SELECT name from customer, SELECT count(*) from products where state='SHIPPED', SELECT count(*) from product where state='PENDING' for all developers
這產量低於上述結果:
name | count_shipped | count_pending
-------+---------------+---------------
xyz1 | 2 | 2
xyz2 | 1 | 0
xyz3 | 0 | 0
xyz4 | 0 | 0
xyz5 | 0 | 0
你使用的是Postgres *和* MySQL的?這是否需要在兩個DBMS上運行? –
我正在使用postgres –
那你爲什麼用MySQL標記它? –