在R中编写Query以从Presto数据库中选择数据时遇到问题。 我用下一个代码
library(DBI)
library(dplyr)
library(RPresto)
res = dbSendQuery(con, " select RESPONDENT as Respondent,RESPONSE_DATE
as Date,
MAX(CASE
WHEN QUESTION_ID = '18' AND RESPONSE_ID ='5' THEN 'Very Satisfied'
WHEN QUESTION_ID = '18' AND RESPONSE_ID ='4' THEN 'Satisfied'
WHEN QUESTION_ID = '18' AND RESPONSE_ID ='3' THEN 'Neutral'
WHEN QUESTION_ID = '18' AND RESPONSE_ID ='2' THEN 'Dissatisfied'
WHEN QUESTION_ID = '18' AND RESPONSE_ID ='1' THEN 'Very Dissatisfied'
ELSE NULL END) AS "How was our service looks based on your last meal?"
from surveytable
group by 1,2")
错误出现在R喜欢
Error: unexpected numeric constant in:
" WHEN QUESTION_ID = '18' AND RESPONSE_ID ='2' THEN
'Dissatisfied'
WHEN QUESTION_ID = '18' AND RESPONSE_ID ='1' THEN 'Very Dissatisfied'
ELSE NULL END) AS "7."
> from dev_bi.Checkmarket_survey_78995
Error: unexpected symbol in " from
dev_bi.Checkmarket_survey_78995"
> group by 1,2
Error: unexpected symbol in " group by"
> limit 1")
Error: unexpected numeric constant in " limit 1"
答案 0 :(得分:1)
您可以使用反斜杠在查询中添加每个双引号。见:
Item1 Item2 Item3 Item4
F G H I
A H D R