简体   繁体   English

选择不同的值并在不同之前计数

[英]select distinct values and count before distinct

table1: 表格1:

pid   fid     year      
1     a       1990
1     a       2002
1     a       2005
3     b       2000
3     b       2002
3     c       1999

i want the result to be : 我希望结果是:

  pid  fid  count
    1    a     3
    3    b     2
    3    c     1

itried 我试过了

select distinct(fid), pid , count(pid)
from table1

any help please thanks. 任何帮助,请谢谢。

select pid, fid, count(*)
from table1
group by pid, fid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM