SQL中最大值和最小值的平均值

时间:2019-04-03 15:34:15

标签: sql database ms-access average

我正在尝试查找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)

1 个答案:

答案 0 :(得分:1)

除以2:

SELECT (MIN(Num) + MAX(Num)) / 2
FROM Table1;