Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

math function - divide

Status
Not open for further replies.

matt969

Technical User
Nov 26, 2003
4
US
I have the following query that I can't get to work...essentially I want to divide one count by another...can anyone help?


select count (*)
from R5events
where evt_completed <=evt_target
and evt_rstatus = 'C'
and evt_person = 'SMITH-MP'
/
select count (*)
from R5events
where evt_person = 'SMITH-MP'
 
depends on the datbase. Try
select
(select count (*)
from R5events
where evt_completed <=evt_target
and evt_rstatus = 'C'
and evt_person = 'SMITH-MP')
/
(select count (*)
from R5events
where evt_person = 'SMITH-MP')

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Hey, that worked - with the addition of &quot;from R5events&quot; on the last line.

Thanks.
 
Sounds like a typical case for a CASE:

select
count(case
when evt_completed <=evt_target
and evt_rstatus = 'C'
then 1
end)
/ count (*)
from R5events
where evt_person = 'SMITH-MP'


Dieter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top