由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 求助:sql, count, group by, union
相关主题
求助:找出现2次及以上的记录怎样快速得到两个表的交集
一个有关查询的语句请教大虾问题哈,包子谢哈
SQL question...How to Import a Datatable as fast as possible?
SQL question: update a field菜鸟问题,急
请教一个oracle下的view的问题问一道SQL的题 (转载)
请教set和select 的区别SQL 查询已经解决.谢谢Modeler,mirthc,cheungche
Question about the err when export tablemysql 问题 (转载)
Help: "Operation Must Be Updatable Query"请教高手,包子谢
相关话题的讨论汇总
话题: product话题: apple话题: count话题: group
进入Database版参与讨论
1 (共1页)
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?
1 (共1页)
进入Database版参与讨论
相关主题
请教高手,包子谢请教一个oracle下的view的问题
请问这个query怎么做请教set和select 的区别
how to write this queryQuestion about the err when export table
请问个join的问题Help: "Operation Must Be Updatable Query"
求助:找出现2次及以上的记录怎样快速得到两个表的交集
一个有关查询的语句请教大虾问题哈,包子谢哈
SQL question...How to Import a Datatable as fast as possible?
SQL question: update a field菜鸟问题,急
相关话题的讨论汇总
话题: product话题: apple话题: count话题: group