I am working with sqlite3 and I’ve created a view named collabs having columns id_1, id_2, count, score.
What I want is to extract data from above view as two rows for one row like if in database data is stored as (11, 44, 3, 55.8)
I want to perform a query that would return (id, count, average)
(11, 3, 55.8)
(4, 3, 55.8)
Advertisement
Answer
That can be done with a union all operation:
select id_1 as id, count, score as average from collabs union all select id_2 as id, count, score as average from collabs
But it is not clear why you called the third column ‘average’, what is it the average of?