Home > database >  Consult the Orcale use Num statistics, how to check the data is empty when returns 0?
Consult the Orcale use Num statistics, how to check the data is empty when returns 0?

Time:09-24

For example, I statistical some data
 select count (*) num, a.a larmlevel 
The from v_customer_alarminfo_now a
Where Anderson srepeat=0
And Anderson, scleared=0
And a.a larmlevel in
(' minor ', 'critical', 'warning' and 'indeterminate', 'major')
Group by a.a larmlevel


Find out the results for the
Num alarmlevel
Four major

How can that do not check the data return 0, such as
Num alarmlevel
0 minor
0 critical
0 warning
0 indeterminate
Four major

CodePudding user response:

 
T1 as
(select the 'minor' as ll from dual
Union all
Select the 'warning' from dual
Union all
Select "indeterminate" from dual
Union all
Select the 'major' from dual)
Select a t1. *, count (*) num from
T1 left join v_customer_alarminfo_now a
On t1. Ll=a.a larmlevel
Where Anderson srepeat=0
And Anderson, scleared=0
Group by t1. Ll

CodePudding user response:

With tmp1 as (
Select 'minor' as f1 from dual
Union all
Select the 'critical' as f1 from dual
Union all
Select the 'warning' from the as f1 dual
Union all
Select "indeterminate" as f1 from dual
Union all
Select the 'major' as f1 from dual
)
Select 1, b. count (a.a larmlevel) from tmp1 b left join v_customer_alarminfo_now a
On a.a larmlevel=1
b.Where Anderson srepeat=0
And Anderson, scleared=0
And a.a larmlevel in
(' minor ', 'critical', 'warning' and 'indeterminate', 'major')
Group by 1
b.;
Into this line, you under reference

CodePudding user response:

  • Related