[SQL ] 从同一个table取值

楼主: roke1845   2015-06-10 18:13:12
数据库名称:HIVE
数据库版本:
内容/问题描述:
资料是这样
0000008201 3 A 002
0000008201 1 A 003
0000008201 5 A 003
想取出结果为
0000008201 3 A 002
0000008201 6 A 003
这是我写的
select f.pid,sum(f.v),f.c from testtry f join testtry s on f.pid=s.pid where
f.a='A' AND f.c=s.c group by f.pid,f.c ;
一直不知道改哪里才会对
作者: rockchangnew (rock)   2015-06-10 19:32:00
不用join自己啊你group by跟sum就可以了
楼主: roke1845   2015-06-10 19:39:00
耶...真的耶感谢大大我知道我卡在哪了-.-.....问了有点蠢的问题 功力不足
作者: popcorny (毕业了..@@")   2015-06-10 21:17:00
不就select前两个就好了吗

Links booklink

Contact Us: admin [ a t ] ucptt.com