Select Count(*) as Rec 
From Table1 Where P In (Select Max(P) as P From Table1 Group By S)
Group By P没测试过~~~~~~~~