2011-11-15 58 views
-2

嗨有一個表名是模式如何統計sql中的重複記錄?

S.No  type  Id_Section 
    1   A  IPS 
    2   A  IPS 
    3   A  IPS 
    4   A  IPS 
    1   B  IPS 
    2   B  IPS 
    3   B  IPS 
    1   C  IPS 
    2   C  IPS 

我想查詢到「A」型......我嘗試了一些examples..But我得到整個記錄count..Please任意一個幫助數紀錄我..

回答

3

SELECT count(*) FROM Pattern where type = "A"

2

如果你想獲得每種類型的計數,你會寫

SELECT 
    type , 
    count (S.No) Kount 
FROM 
    Pattern 
GROUP BY 
    type