如何让sum函数在rodbc的sqlquery中工作

jgwigjjp  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(365)

我在hadoop impala中有一个作为sql查询使用的脚本,但是当我尝试使用包rodbc在r中运行时,如果使用“sum”函数,则只有一行会产生错误,如下所示:

install.packages("RODBC")
library(RODBC)
conn <- odbcConnect("ODBC Impala")

example1 <- sqlQuery(conn, "
select
    column1 as Name, column2 as Date, sum(column3) as Balance
from 
    database1.table1
where 
    column2="20151130"")

但是当我排除:

sum(column3) as Balance

脚本运行得很好。有人能帮忙吗?

a0x5cqrl

a0x5cqrl1#

大概,你需要一个 group by :

select column1 as Name, column2 as Date, sum(column3) as Balance
from  database1.table1
where column2 = '20151130'
group by column1, column2;

相关问题