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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Division

Status
Not open for further replies.

IAMINFO

MIS
Feb 21, 2002
62
US
Hello everyone

I am not sure how to proceed. I would like
to divide recidivism / releaseDate


select count(*) from recidivism
select count (*) from releaseDate

Thank you for helping if you can.
 
declare @Cnt1 int, @cnt2 int

select @cnt1 = count(*) from recidivism

select @cnt2 = count (*) from releaseDate

select coalesce(cast(@cnt1/nullif(@cnt2,0) as decimal(19,4)),0) as FinalResult, @cnt1 as Count1, @cnt2 as Count2
 
thanks for helping, i need to elaborate

my count from recidivism is 43258
my count from released is 38422

I need to return the percentage

43258 is what percent of 38422

Thanks again
 
Code:
SELECT 100.0 
     * ( select count(*) from recidivism )
     / ( select count(*) from releaseDate ) AS percent

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Multiple my code by 100.00 if you want to get percentage.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top