CREATE TABLE TEMP25
(
STATUS VARCHAR2(200 BYTE)
);
Insert into TEMP25
(STATUS)
Values
('PENDING');
Insert into TEMP25
(STATUS)
Values
('ERROR');
Insert into TEMP25
(STATUS)
Values
('ERROR');
Insert into TEMP25
(STATUS)
Values
('ERROR');
Insert into TEMP25
(STATUS)
Values
('NOT_REQUIRED');
Insert into TEMP25
(STATUS)
Values
('NOT_REQUIRED');
Insert into TEMP25
(STATUS)
Values
('PENDING');
Insert into TEMP25
(STATUS)
Values
('PENDING');
Insert into TEMP25
(STATUS)
Values
('ERROR');
Insert into TEMP25
(STATUS)
Values
('NOT_REQUIRED');
Insert into TEMP25
(STATUS)
Values
('ERROR');
Insert into TEMP25
(STATUS)
Values
('INVALID');
Insert into TEMP25
(STATUS)
Values
('INVALID');
Insert into TEMP25
(STATUS)
Values
('PENDING');
I want to write a query such that i get count like
TOTAL_RECORDS TOTAL_PENDING TOTAL_NOT_REQUIRED TOTAL_PENDING
-----------------------------------------------------------------
14 4 3 5
-----------------------------------------------------------------
I want the record in sequence and in one query , i ahve tried with with table clause it works …is there any other solution …and dnt want invalid records
You can use
SUM/CASEor (SUM/DECODEif you prefer)See it working here
You can also use pivot but getting the count(*) is a little ugly
Pivot version