केवल सशर्त एकत्रीकरण का उपयोग करें:
SELECT SUM(CASE WHEN STATUS = 'A' THEN 1 ELSE 0 END) AS A_COUNT ,
SUM(CASE WHEN STATUS = 'B' THEN 1 ELSE 0 END) AS B_COUNT ,
SUM(CASE WHEN STATUS = 'C' THEN 1 ELSE 0 END) AS C_COUNT ,
SUM(CASE WHEN STATUS = 'D' THEN 1 ELSE 0 END) AS D_COUNT ,
SUM(CASE WHEN STATUS = 'E' THEN 1 ELSE 0 END) AS E_COUNT ,
SUM(CASE WHEN STATUS = 'F' THEN 1 ELSE 0 END) AS F_COUNT
FROM XYZ ;
मुझे यह बताना चाहिए कि मानों को अलग-अलग पंक्तियों में रखना और भी आसान है:
select status, count(*)
from xyz
group by status;