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

时间:2015-12-07 22:02:44

标签: mysql sql

表1:

using (PowerShell PowerShellInstance = PowerShell.Create())
{
    string script = "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted; Get-ExecutionPolicy"; // the second command to know the ExecutionPolicy level
    PowerShellInstance.AddScript(script);
    var someResult = PowerShellInstance.Invoke();
    something.ToList().ForEach(c => Console.WriteLine(c.ToString()));
    Console.ReadLine();
}   

我希望结果为:

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

itried

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

请帮助 感谢。

1 个答案:

答案 0 :(得分:2)

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