我有一个要在R Studio中进行分析的查询。以下查询是:
SELECT D.Company,E.MachineType,E.MachineRequired,D.BulletinID,D.UseDate,D.daycnt,D.Line,D.FileRefID,D.OrderRef,D.Style FROM(
SELECT Company,BulletinID,Count(Line) daycnt,UseDate,FileRefID,orderref,Line ,style FROM (
SELECT x.Line, x.orderref, x.UseDate, x.Company, x.BulletinID,x.FileRefID,c.StyleName style FROM(
SELECT Line, Orderref, UseDate, BulletinID, filerefid, Company FROM (
SELECT Line,orderref,usedate,m.BulletinID,filerefid,M.Company FROM (
SELECT Factory, b.[Line No] Line,[Order Ref] orderref,fm.dbo.dateonly(CAST(GETDATE() AS DATE)) usedate,[BisFileID] filerefid
FROM BitopiSplint.dbo.['os-2$'] b
WHERE b.[Date]=CAST(GETDATE() AS DATE)) b
JOIN (SELECT BulletinID,FileRef,Company FROM ProcessOBmaster) m on b.filerefid=m.FileRef ) t)x
INNER JOIN FileRef fr on x.FileRefId=fr.FileRefID
INNER JOIN Style_Master c on fr.StyleID=c.StyleId)T
GROUP BY Company,BulletinID,UseDate,orderref,FileRefID,Line,style)D
INNER JOIN
(SELECT MachineType, d.BulletinID,sum(isnull(PlannedWs,0))MachineRequired
From ProcessOBDetails as d
JOIN [BitopiSplint].[dbo].[tblOperationCategory_Details] n on d.MachineType=n.ItemName and isnull(n.IsDashBoadApplicable,0)=1
WHERE isnull(MachineType,'')!=''
GROUP BY d.BulletinID,MachineType)E on D.BulletinID=E.BulletinID
但是如何执行它并用作数据框可以帮助我。甚至有可能在r中执行这样的查询。
已为服务器设置ODBC连接。