开发者

I want to use field from select statement in AVG function in Mysql

开发者 https://www.devze.com 2023-03-05 18:46 出处:网络
select count(distinct installation_id), SUM(hit_block), AVG(???) T开发者_如何学Gohis is the select statement. I want to divide the value returned by first field (count(distinct installation_id)) by
select count(distinct installation_id), SUM(hit_block), AVG(???)

T开发者_如何学Gohis is the select statement. I want to divide the value returned by first field (count(distinct installation_id)) by the second field. Please suggest me how to do it.


select count(distinct installation_id)/SUM(hit_block),AVG(??)

Basically you can do numerical operations in between what could be separate selectable clauses.

I'm not sure what you want to find the average of?


i dont think i understand very clearly what is it that you want to do, perhaps if you add an example data set, and the a description of the problem you are trying to solve by running that query, if what you want to do is just divide you can apply the arithmetic operands

note that this is just an example and wont probably work as i dont have a way of testing this on your enviroment

SELECT (COUNT(DISTINCT installation_id) / SUM(hit_block))
       ,AVG(???)
FROM ????
GROUP BY ????

note that you should probably replace the question marks with real values ???, is this what you were looking for? if not please explain i can probably still help

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号