将java SQL查询转换为R编程SQL查询
我有一个java将java SQL查询转换为R编程SQL查询,java,mysql,sql,r,Java,Mysql,Sql,R,我有一个javaSQL查询,我想使用RMySQL包将其转换为R编程SQL查询 这是我的java SQL查询: String Statement1 = "((Time_To_Sec((case when shift_to >= shift_from then TIMEDIFF(shift_to,shift_from) else TIMEDIFF('24:00:00',TIMEDIFF(shift_from,shift_to)) end))-" + "
SQL
查询,我想使用RMySQL包将其转换为R
编程SQL
查询
这是我的java SQL查询:
String Statement1 = "((Time_To_Sec((case when shift_to >= shift_from then TIMEDIFF(shift_to,shift_from) else TIMEDIFF('24:00:00',TIMEDIFF(shift_from,shift_to)) end))-" +
" (case when lunch_from is not null then TIME_TO_SEC(TIMEDIFF(lunch_to,lunch_from)) else 0 end)-" +
" (case when break1_from is not null then TIME_TO_SEC(TIMEDIFF(break1_to,break1_from)) else 0 end)- " +
" (case when break2_from is not null then TIME_TO_SEC(TIMEDIFF(break2_to,break2_from))else 0 end))/3600)";
如何将此javaSQL
支持的查询转换为R
编程支持的查询。我正在使用RMySQL包
。我这样做,但不起作用:
Statement1 = dbGetQuery(mydb , "((Time_To_Sec((case when shift_to >= shift_from then TIMEDIFF(shift_to,shift_from) else TIMEDIFF('24:00:00',TIMEDIFF(shift_from,shift_to)) end))-" +
" (case when lunch_from is not null then TIME_TO_SEC(TIMEDIFF(lunch_to,lunch_from)) else 0 end)-" +
" (case when break1_from is not null then TIME_TO_SEC(TIMEDIFF(break1_to,break1_from)) else 0 end)- " +
" (case when break2_from is not null then TIME_TO_SEC(TIMEDIFF(break2_to,break2_from))else 0 end))/3600)")
谢谢像通常一样将sql查询编写为一行。或者将字符串包装在粘贴中,并将+
替换为,
。这不是符合要求的sql查询-否从子句中选择或。您的Java语句是否被切断?使用paste并将+替换为,也不起作用。给出了一些SQL语法错误。请像通常一样将SQL查询写为一行。或者将字符串用粘贴,并将+
替换为,
。这不是符合要求的SQL查询-否选择或FROM
子句。您的Java语句是否被切断?使用paste并将+替换为,也不起作用。给出了一些SQL语法错误。