顯示具有 SQL 標籤的文章。 顯示所有文章
顯示具有 SQL 標籤的文章。 顯示所有文章

2012年7月2日 星期一

Distinct

SELECT DISTINCT table_column1, table_column2···
FROM table_name;
可以將資料只有一筆,
避免重複,


distinct column




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