rsqlite_send_query(conn@ptr, statements) 中的错误:“.”附近:语法错误

问题描述 投票:0回答:1
q1<- dbGetQuery(conn,
                "SELECT UNIQUELETTERCODE_y , 
                        COMPLETION.MODE, 
                        COMPLETED.BY, 
                        Current.Status, 
                        Completed.by.which.group 
                    FROM Daily_Returns 
                      WHERE AgentName IS NULL AND
                            CASEID IS NULL AND
                            Completed.by.which.group = OUTBOUND AND
                            Current.Status = Completed AND
                            (COMPLETED.BY = CALL OR
                            COMPLETED.BY = CISCO OR
                            COMPLETED.BY = MOBILE) AND
                            COMPLETION.MODE =CALL 
                        GROUP BY UNIQUELETTERCODE_y
                ")

使用上面的代码一直提示这个Error: Error in rsqlite_send_query(conn@ptr, statements) : close ".": 语法错误,知道如何解决这个问题吗?

sql r sqlite
1个回答
0
投票

您的查询中有拼写错误。这是一个固定的查询:

"
SELECT DISTINCT UNIQUELETTERCODE_y, 
                                 COMPLETION_MODE, 
                                 COMPLETED_BY, 
                                 Current_Status, 
                                 Completed_by_which_group 
                  FROM Daily_Returns 
                  WHERE AgentName IS NULL AND
                        CASEID IS NULL AND
                        Completed_by_which_group = 'OUTBOUND' AND
                        Current_Status = 'Completed' AND
                        (COMPLETED_BY = 'CALL' OR
                         COMPLETED_BY = 'CISCO' OR
                         COMPLETED_BY = 'MOBILE') AND
                        COMPLETION_MODE = 'CALL'
"
  1. 您必须为每个 where 参数添加
    '
    ,例如
    'OUTBOUND'
    'Completed'
  2. 防止在列名称上使用
    .
    。在 SQL 中,句点 (.) 通常用于限定表名或列名,并且列名不直接支持点表示法。在大多数情况下,列名称不能包含句点。
© www.soinside.com 2019 - 2024. All rights reserved.