Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL (Oracle) -How to Get Ratio from two Count Statements?

I want to get the Ratio of count1 / count2
which gives me percent compliant. this is right beneath my finger tips...
Can I get some help?

Select 
 (
 Select Count (*) from tso_skf_nomeas_in60days_v 
 ) as count1, 
 (
 Select Count (*) from tso_skf_recent_meas
 ) as count2
 (
 from dual
like image 498
Ben_Coding Avatar asked Oct 22 '25 04:10

Ben_Coding


1 Answers

You're pretty close:

Select 
    (Select Count (*) from tso_skf_nomeas_in60days_v) 
    / 
    (Select Count (*) from tso_skf_recent_meas) as perc
from dual

SQL Fiddle Demo

like image 88
sgeddes Avatar answered Oct 23 '25 19:10

sgeddes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!