
My query is- http://sqlfiddle.com/#!17/9e89e/761
On average profit, the formula needs to group by aggregate function.So not getting required profit My query is attached above link and the required output is attached by image. please help me.

My query is- http://sqlfiddle.com/#!17/9e89e/761
On average profit, the formula needs to group by aggregate function.So not getting required profit My query is attached above link and the required output is attached by image. please help me.
You can get the count of the different universe first using count(*) over (partition by u.universe) and after that you can apply your logic to calculate profit like the following query.
select c.id,c.name,u.universe,u.budget,u.revenue
,(revenue - budget) / count(*) over (partition by u.universe) as profit
from universe u
inner join characters c on u.id = c.universe_id
order by u.universe desc
Check the updated fiddle here
count(*) over (...) directly.