I can't figure out how to escape these quotes properly. How can I add SQL that requires quotes to denote strings near 'australia' and 'brazil'? The following as run in R Studio as R markdown.
Error message is below.
---
title: "Mobile Product Reporting"
author: "super john"
date: "Thursday, May 07, 2015"
output: html_document
---
<h1>Regional Summary</h1>
```{r echo = FALSE}
library(RODBC)
conn <- odbcConnect("db_connection")
regional <- sqlQuery(conn, 'select
month_year, region, round(sum(revenue), 2) as revenue
from
db.data_table
where lower(region) <> 'australia'
and lower(region) <> 'brazil'
and region is not null
group by month_year , region
order by date')
knitr::kable(regional)
```
ERROR MESSAGE
Quitting from lines 39-51 (Preview-3ac1bc22a.Rmd)
Error in parse(text = x, srcfile = src) : <text>:7:25: unexpected symbol
6: rfi_analytics.jh_monthly_mobile2
7: where lower(region) <> 'australia
^
Calls: <Anonymous> ... evaluate -> parse_all -> parse_all.character -> parse
Execution halted
Strings are delimited by '
or "
, so you cannot toss those into a middle of a string. This works:
"string 'australia' string"
The knitr, RODBC, MYSQL stuff is a distraction here. Documentation at ?Quotes