clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1451489 fiddles created (18760 in the last week).

CREATE TABLE tbl (customerID varchar(10), status int); INSERT INTO tbl VALUES ('XXX', 1), ('XXX', 2), ('XXX', 3), ('YYY', 2), ('YYY', 2), ('XXX', 1), ('XXX', 4), ('YYY', 4);
8 rows affected
 hidden batch(es)


SELECT customerID, [1], [2], [3], [4] FROM ( SELECT customerID, status FROM tbl ) src PIVOT ( COUNT(status) FOR status IN ([1], [2], [3], [4]) ) pvt;
customerID 1 2 3 4
XXX 2 1 1 1
YYY 0 2 0 1
 hidden batch(es)