0

enter image description here

Above if I generated a SQL query that produced the defined table and an "R" summary dataframe that produced the defined table, how you I be able to link them both together into production.

*Note, I'm not asking how to create a SQL query or an R Dataframe for the defined tables (I have the code for that), but rather how can they both work together. For example, could that R dataframe code be used in SQL Server (I have the latest version) so that as soon as the SQL query created the tables (BY DATE), the summary table would automatically update itself (BY DATE) in SQL Server?

So as soon as it went aggregated the summary of the first date, it would move onto the next and essentially generate (stack on top of each other)

Thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
puj831
  • 109
  • 7
  • 1
    If both data frames are in R, you can merge the data in R with `merge` [or any of the other options described here](https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right). If you want SQL to be able to use the data from R, you need R to give the data to SQL. Whatever package you are using to connect to the data base almost certainly has functions for that. Though if it's a simple summary, it wouldn't seem that R is adding much value - it is much simpler to do all the work in SQL. – Gregor Thomas Jun 11 '18 at 16:16
  • 3
    This question is a bit to broad for SO. You can use R (or Python) within SQL Server using the Machine Learning. See https://learn.microsoft.com/en-us/sql/advanced-analytics/getting-started-with-machine-learning-services?view=sql-server-2017 for starters. However, are you sure you need R for the summary? At first sight it looks like a simple `SUM` with `GROUP BY`. – Ralf Stubner Jun 11 '18 at 16:17
  • Agreed with Ralf - it is not clear what you mean by "use in production". Or really what you mean by "automatically update". Is the work in R? In something else? What is the production use - is there an API calling R? – Gregor Thomas Jun 11 '18 at 16:19
  • just sample data..obviously if its a simple summary I would use SQL, but it was much more complex than that, so I used R. I have the SQL Queries in R so it is connected to the SQL Server. The way my query is set up is that it just takes a certain date defined from SQL Query such as 1/1/2017 and then R does all the complex manipulations for that date only and writes it back to the SQL Server in a separate table. What I would like to do is after come back and do 1/2/2017 and write that back into the SQL Server AFTER 1/1/2017 and so on. How can I do that? Thanks! – puj831 Jun 11 '18 at 17:14

0 Answers0