Home » SQL & PL/SQL » SQL & PL/SQL » divide the values of 2 sql statements
divide the values of 2 sql statements [message #8993] Thu, 09 October 2003 09:47 Go to next message
Hugh
Messages: 7
Registered: April 2002
Junior Member
Hi,

Say I have 2 sql statements that both return a numeric value.
eg
a. select count(*) from inspectors
b. select count(*) from inspections

Can I create 1 sql statement that give the answer to (b/a)

like

select trunc((select count(*) from inspections) / (select count(*) from inspectors));

Thanks
Re: divide the values of 2 sql statements [message #8994 is a reply to message #8993] Thu, 09 October 2003 11:04 Go to previous message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
thiru@9.2.0:SQL>select b.CNT/A.CNT from
2 ( select count(*) CNT from user_tables) B,
3 ( select count(*) CNT from user_indexes) A;

B.CNT/A.CNT
-----------
10

thiru@9.2.0:SQL>select count(*) from user_tables;

COUNT(*)
----------
10

thiru@9.2.0:SQL>select count(*) from user_indexes;

COUNT(*)
----------
1
Previous Topic: v8.0: doing a MENU how to stop Oracle on the input value ?
Next Topic: functions
Goto Forum:
  


Current Time: Thu Apr 25 07:25:05 CDT 2024