How to execute sum(a)/sum(b) query in MSSQL?
How to execute `sum(a)/sum(b)` query in MSSQL?

I have subquery with `a = sum(...)` and `b = count(...)`. I need to calculate `avg(all)` for all records from subquery in the main query. It's `avg(all) = sum(a)/sum(b)`. But MSSQL doesn't permit this expression. How to calculate it? The count of records in the main query can't be changed.

Thanks a lot for the help!
How to execute sum(a)/sum(b) query in MSSQL?
===

How to execute `sum(a)/sum(b)` query in MSSQL?

I have subquery with `a = sum(...)` and `b = count(...)`. I need to calculate `avg(all)` for all records from subquery in the main query. It's `avg(all) = sum(a)/sum(b)`. But MSSQL doesn't permit this expression. How to calculate it? The count of records in the main query can't be changed.

Thanks a lot for the help!