我有一张如下表(MSSql)
Name Status
---- -------
kmk Success
kmk Success
mvk Fail
per Success
Per Fail
mvk Fail
我需要给出如下结果的查询
Name Status Count
---- ------- -----
kmk Success 2
kmk Fail 0
mvk Success 0
mvk Fail 2
Per Success 1
Per Fail 1
我试过了,group by
但我得到了如下结果我的查询是
(Select Name,[Status],COUNT([Status]) As Count From Checking group by [Status],Name)
Name Status Count
---- ------- -----
kmk Success 2
mvk Fail 2
Per Success 1
Per Fail 1
我尝试了很多方法,请您给我查询