hello,
i'm trying to build an application through r shiny. i'm having problems with converting sql syntax into syntax that is available in r.
Variables can be passed to SQL statements using paste. Below is how sql syntax looks:
SELECT BRKNo,SEX,BIRTHDAY,LAST_DATE,[ADDRESS],TEL_H_1,INVEST,C_Type,WRNT_REG_DATE,WRNT_CNCL_DATE,APL_FLAG,datediff(year,BIRTHDAY,getdate()) AS age
FROM dbo.SCUST
WHERE dbo.SCUST.CustNo not in (select custNo FROM dbo.WCKEY) AND [ADDRESS] not like '%testing%' AND [ADDRESS] not like '%XX%'
I've tried to convert a part and it does work. But i'm stuck when converting the WHERE part. How can I solve this?
Below is how it looks like in r currently:
library(shiny)
library(RODBC)
conn <- odbcDriverConnect("driver={SQL Server};server=;database=;uid=;pwd=")
shinyServer(function(input, output) {
output$dataset1 <- renderTable ({
conn <- odbcDriverConnect("driver={SQL Server};server=;database=;uid=;pwd=")
queried <- sqlQuery(channel = conn, query = "select
BRKNo
,SEX
,BIRTHDAY
,LAST_DATE
,[ADDRESS]
,TEL_H_1
,INVEST
,C_Type
,WRNT_REG_DATE
,WRNT_CNCL_DATE
,APL_FLAG
,datediff(year,BIRTHDAY,getdate()) AS age
FROM dbo.SCUST")
dataset1 = queried
})
})
Any help is appreciated.