If what you want is that your view has several independent columns, you can do it in the following way:
CREATE VIEW miVista AS SELECT
(SELECT .... FROM ....) AS columna1,
(SELECT .... FROM ....) AS columna2,
...
(SELECT .... FROM ....) AS columnaN;
In your case, it would be something like this:
CREATE VIEW 'calificacion_videos2' AS SELECT
(SELECT (sum('calificacion'.'calificacion') / count(0)) from 'calificacion' where ('calificacion'.'Tipo' = 'video' and 'calificacion'.'categoria' = 'Ovni')) AS cal_video_ovni,
(SELECT (sum('calificacion'.'calificacion') / count(0)) from 'calificacion' where ('calificacion'.'Tipo' = 'video' and 'calificacion'.'categoria' = 'Misterio')) AS cal_video_misterio,
(SELECT (sum('calificacion'.'calificacion') / count(0)) from 'calificacion' where ('calificacion'.'Tipo' = 'video' and 'calificacion'.'categoria' = 'Leyendas')) AS cal_video_leyendas;
That will create a view with a single row and three columns (one for UFO, another for Mystery and another for Legends) with the calculations for each of them. You just have to extend it to the rest of the categories you have:
cal_video_ovni | cal_video_misterio | cal_video_leyendas
----------------+---------------------+--------------------
6.3 | 6.2 | 7.3
But I would almost tell you that if you want to get the rating by category, maybe it would be better to change how the view is created so that it makes the calculations for all hit categories (using GROUP BY
), the only thing is that instead of being 1 row with 9 columns, there would be 9 rows with 2 columns (category and calculated value):
categoria | calificacion
----------------+---------------------
Ovni | 6.3
Misterio | 6.2
Leyendas | 7.3
It would be something like this (I have not tried it and it may contain some error):
CREATE VIEW 'calificacion_videos2' AS
SELECT categoria, (sum('calificacion'.'calificacion') / count(0))
FROM 'calificacion'
WHERE 'calificacion'.'Tipo' = 'video'
GROUP BY 'calificacion'.'categoria'