Q:

How to achieve this output? 

I have a table with data like this :
create table test (transferID int, customerNumber varchar(10), txnstatus int);
insert into test
values
    (1,  1001, 1),
    (2,  1001, 2),
    (3,  1001, 1),
    (4,  1002, 2),
    (5,  1002, 1),
    (6,  1002, 2),
    (7,  1002, 1),
    (8,  1002, 1),
    (9,  1003, 2),
    (10, 1003, 1),
    (11, 1003, 1),
    (12, 1003, 1),
    (13, 1003, 1),
    (14, '  ', 1),
    (15, '  ', 2),
    (16, NULL, 2);

and the excepted output is to display the fields with customer number, total number of txns for each customer, successfulTxns, failedTxns.  Note that:

txnStatus 1 and 2 represent "success" and "fail" respectively. 
customer number may be empty or NULL in some cases like last three rows

This is how I tried, but didn't get the excepted result
select customerNumber,
       count(*) over (partition by 1) as TotalTxns,
       case when txnstatus = 1 then count(txnstatus) else 0 end as successFulTrxn,
       case when txnstatus = 2 then count(txnstatus) else 0 end as failedFulTrxn
from test
group by customerNumber, txnstatus

I expect the output to be:
CustNumber   TotalTxns    SuccessFulTxns    FailedTxns
1001         3             2                 1
1002         5             3                 2
1003         5             4                 1
             2             1                 1
NULL         1             0                 1

A:

Your logic is somewhat correct, you just need to put the CASE expression inside COUNT, not the other way round:
SELECT customerNumber
     , COUNT(*) AS TotalTxns
     , COUNT(CASE WHEN txnstatus = 1 THEN 1 END) AS SuccessFulTxns
     , COUNT(CASE WHEN txnstatus = 2 THEN 1 END) AS FailedTxns
FROM test
GROUP BY customerNumber

Note that there is not such thing as empty INT.  Empty strings/whitespace becomes 0 when converted to INT.