Reference : https://youtu.be/DwzIx7CEn0Y
Package : RODBC
installing package
install.packages("RODBC")
library(RODBC)
Connection
myConn <- odbcConnect("ODBC_SQLServer")
Running SQL in R
res <- sqlQuery(myConn, "SELECT *
FROM TSOM_MSSQL.dbo.Customers")
res
res2 <- sqlQuery(myConn,"
select
CustomerName as 'Name',
PricePerItem as Price,
avg(PricePerItem) over (partition by CustomerName) as 'Customer Mean'
from TSOM_MSSQL.dbo.orders3")
View(res2)
Comments