2011-08-28 8 views
0

그것의 쉬운 질문 만 하드에 대한 항목의 수를 계산 : 나는 다음 표 (열)이나를 위해 아마 주어진 열

[id, email_from, email_to, email_subject, timestamp] 

ID와 타임 스탬프 숫자이며, 나머지는 텍스트 필드입니다

그 예를 들어

:

[1, [email protected], [email protected], ...] 
    [2, [email protected], [email protected], ...] 
    [3, [email protected], [email protected], ...] 
    [4, [email protected], [email protected], ...] 
    [5, [email protected], [email protected], ...] 
    [6, [email protected], [email protected], ...] 
    [8, [email protected], [email protected], ...] 
    [9, [email protected], [email protected], ...] 

나는 각 사용자가 보낸 메일의 수를 검색하고 싶습니다.

[[email protected],4] 
[[email protected],3] 
[[email protected],1] 

감사

답변

2
select email_from, count(*) from yourtable group by email_from 

당신이 그것을 적어도 이메일에 대부분의 지시하려면 가능성이 수 (*) DESC

하여

순서를 추가 : 결과는 같이해야한다 보낸 사람

0

SELECT email_from, COUNT (email_from) AS '개수' FROM table_name GROUP BY email_from

관련 문제