我正在尝试查找SQL中最小值和最大值的平均值,但是我的代码不起作用。
df_l = list(df1 = data.frame('A'=rep("f1",10),'B'=runif(10),'C'=seq(1:10)),
df2 = data.frame('A'=rep("f2",20),'B'=runif(20),'D'=paste0("X",seq(1:20))),
df3 = data.frame('A'=rep("f3",30),'C'=seq(1:30),'D'=paste0("Y",seq(1:30))))
all_names = unique(c(colnames(df_l[['df1']]),
colnames(df_l[['df2']]),
colnames(df_l[['df3']])))
for (i in names(df_l)) {
abs_col = all_names[!all_names %in% names(df_l[[i]])]
if(length(abs_col) > 0) df_l[[i]][,abs_col] <- NA
} ; rm(i)
do.call("rbind", df_l)
答案 0 :(得分:1)
除以2:
SELECT (MIN(Num) + MAX(Num)) / 2
FROM Table1;