Here's the query:
select
(
SELECT COUNT(*)
FROM Sending s
WHERE (ConfID = 1) AND (Status = 1)
)
/
(
(
SELECT COUNT(*)
FROM Numbers
WHERE (ConfID = 1)
)
/
100
)
I want to compute percent. For instance, if query
SELECT COUNT(*)
FROM Numbers
WHERE (ConfID = 1)
gives 100 and the another one
SELECT COUNT(*)
FROM Sending s
WHERE (ConfID = 1) AND (Status = 1)
results 50 the result query should return 50, which means 50%. But is first query results with 2 and second returns 10000 the result query returns 0. I think I should define somehow to return float number or so on.
Thanks!
Try dividing by 100.0
instead of 100
. That will force a cast to floating point data type:
select
(
SELECT COUNT(*)
FROM Sending s
WHERE (ConfID = 1) AND (Status = 1)
)
/
(
(
SELECT COUNT(*)
FROM Numbers
WHERE (ConfID = 1)
)
/
100.0
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With