-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql-queries.Rmd
44 lines (35 loc) · 926 Bytes
/
sql-queries.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
title: "Behind the scenes - Show SQL queries"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{sql-queries}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r setup}
library(nottshcOpenData)
# Create MySQL connection
# Note, the driver name, here "MySQL ODBC 8.0 ANSI Driver", may differ on your computer
conn_mysql_suce <- connect_mysql(database = "SUCE",
driver = "MySQL ODBC 8.0 ANSI Driver")
```
### 1. SQL code used to query data
```{r}
# Get database (db_) connection for specified date range
get_px_exp(from = "2020-01-01",
to = "2020-12-31") %>%
dplyr::show_query()
```
### 2. SQL code used to tidy data
```{r}
get_px_exp(from = "2020-01-01",
to = "2020-12-31") %>%
tidy_px_exp() %>%
dplyr::show_query()
```