2
--select P,N,Pa,Count(Tq)as tq,BDate,EDate from table group by P,N select P,N,Count(Tq)as tq from table group by P,N
5
select P,N,Count(Tq)as tq from table group by P,N
select p,n ,pa=(select top 1 pa from table where p=a.p and n=a.n ) ,tq=count(tq) ,bdate=(select top 1 bdate from table where p=a.p and n=a.n ) ,edate=(select top 1 edate from table where p=a.p and n=a.n ) from table a group by p,n
select P,N,Pa,Count(Tq)as tq from table group by P,N
select P,N,sum(Tq)as tq from table group by P,N