sqlite3查询执行两次操作
sqlite3 query to perform a operation twice
我正在使用 sqlite3,我创建了一个名为 collabs 的视图,其中包含 id_1、id_2、count、score 列。
我想要的是从上面的视图中将数据提取为一行两行,就像在数据库中数据存储为 (11, 44, 3, 55.8)
我想执行一个 return (id, count, average) 的查询
(11, 3, 55.8)
(4, 3, 55.8)
这可以通过 union all 操作来完成:
select id_1 as id, count, score as average from collabs
union all
select id_2 as id, count, score as average from collabs
但是不清楚为什么叫第三列'average',它的平均值是多少?
我正在使用 sqlite3,我创建了一个名为 collabs 的视图,其中包含 id_1、id_2、count、score 列。
我想要的是从上面的视图中将数据提取为一行两行,就像在数据库中数据存储为 (11, 44, 3, 55.8)
我想执行一个 return (id, count, average) 的查询
(11, 3, 55.8)
(4, 3, 55.8)
这可以通过 union all 操作来完成:
select id_1 as id, count, score as average from collabs
union all
select id_2 as id, count, score as average from collabs
但是不清楚为什么叫第三列'average',它的平均值是多少?