n********6 发帖数: 1511 | 1 current output:
product, counter
apple 2
apple 3
orange x
Objective:
product, counter
apple 5
orange x
table1
transactionid, product
1, apple
2, orange
3, apple
...
m, banana
table2
transactionid, product
1, peach
2, apple
3, apple
...
n, apple
current code (to be modified)
select product, count(transactionid)
from table1
group by product
union
select product, count(transactionid)
from table2
group by product | i****a 发帖数: 36252 | 2 select prodcut, sum(cnt)
(
select product, count(transactionid) as cnt
from table1
group by product
union ALL
select product, count(transactionid) as cnt
from table2
group by product
) x
group by x.product | n********6 发帖数: 1511 | 3 thank you very much.
【在 i****a 的大作中提到】 : select prodcut, sum(cnt) : ( : select product, count(transactionid) as cnt : from table1 : group by product : union ALL : select product, count(transactionid) as cnt : from table2 : group by product : ) x
| B*****g 发帖数: 34098 | 4 你去参加session3吧
【在 n********6 的大作中提到】 : current output: : product, counter : apple 2 : apple 3 : orange x : Objective: : product, counter : apple 5 : orange x : table1
| n********6 发帖数: 1511 | 5 what is that?
【在 B*****g 的大作中提到】 : 你去参加session3吧
| B*****g 发帖数: 34098 | 6 版上还有不知道的吗?
【在 n********6 的大作中提到】 : what is that?
|
|