sqlite按均值对每个组均值丢失值
我有一个Sqlite表,如下所示。
学生 | 成绩 |
---|---|
尼克 | 34 |
尼克 | 42 |
尼克 | 86 |
· | 纳尔约翰 |
尼克 | 38 |
约翰 | 12 |
约翰 | 74 |
约翰· | 纳尔 |
·科林 | 87 |
科林 | 23 |
科林 | 46 |
科林 | 42 |
我想做的是将无效的值与每个学生的成绩的平均值相关。 例如,尼克的缺失价值将为54,而约翰41.3的价值将为54。 如何在SQL代码中执行此操作?我正在使用sqlite。
I have an SQLite table as shown below.
students | grades |
---|---|
Nick | 34 |
Nick | 42 |
Nick | 86 |
Nick | Null |
John | 38 |
John | 12 |
John | 74 |
John | Null |
Colin | 87 |
Colin | 23 |
Colin | 46 |
Colin | 42 |
What I want to do is impute Null values with the mean of each student's grades.
For example, missing value for Nick will be 54 and for John 41.3.
How can I do this in SQL code? I am using SQLite.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在更新语句中使用相关的子查询:
请参阅
Use a correlated subquery in the UPDATE statement:
See the demo.