2012年7月2日 星期一

Group By Having

Group By: is seperating the  data query condtion,
having: is the filter condition after the group,
Aggregation function: using in group query


-- 使用 group 找出相同內容
select i.sample  ||  '.' || i.chr || '.' || i.pos || '.' || i.type as mykey,
count(i.sample  ||  '.' || i.chr || '.' || i.pos || '.' || i.type) as counts
from gra.gra_indels_het_homo_target_testDel as i
group by i.sample  ||  '.' || i.chr || '.' || i.pos || '.' || i.type
having  count(i.sample  ||  '.' || i.chr || '.' || i.pos || '.' || i.type) > 1



reference:
http://news.csdn.net/n/20061123/98120.html
http://tomkuo139.blogspot.tw/2008/11/group-by-having.html

沒有留言:

張貼留言