I have the following example table. Tera can be unlimited affiliate and customers. I need to group these branches and count their customers, and then show them in different columns.
BRANCHNAME CUSTOMERNO 100 1001010 100 1001011 103 1001012 104 1001013 104 1001014 104 1001015 105 1001016 105 1001017 106 1001018
Please note that there is an unlimited branch and clients, the request should work not only in this case.
In this case, the accepted result:
100 103 104 105 106 2 1 3 2 1
SQL DATA Example
select '100' BranchName,'1001010' CustomerNo from dual UNION ALL select '100' BranchName,'1001011' CustomerNo from dual UNION ALL select '103' BranchName,'1001012' CustomerNo from dual UNION ALL select '104' BranchName,'1001013' CustomerNo from dual UNION ALL select '104' BranchName,'1001014' CustomerNo from dual UNION ALL select '104' BranchName,'1001015' CustomerNo from dual UNION ALL select '105' BranchName,'1001016' CustomerNo from dual UNION ALL select '105' BranchName,'1001017' CustomerNo from dual UNION ALL select '106' BranchName,'1001018' CustomerNo from dual
user7479343
source share