全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
948 0
2016-04-05
悬赏 20 个论坛币 未解决
如题 对SQL的结构不是很了解,因为只是个参考的code 被要求转到R上面用RSQLite。。。。有对应的R代码能把这些相应的代码用R实现么?

CREATE INDEX IF NOT EXISTS idx1_firstcontact ON firstcontact (studentid);                           --create index
CREATE INDEX IF NOT EXISTS idx2_firstcontact ON firstcontact (studentid ,createddate,modifieddate); --create index


with
firstcontact_std
   as
   ( select   studentid         
             ,date(createddate)  createddate        
             ,date(modifieddate) modifieddate
                 from firstcontact
              group by studentid,date(createddate),date(modifieddate))
,firstcontact_res
   as
   ( select   studentid         
             ,date(createddate)  createddate        
             ,date(modifieddate) modifieddate
             ,responselabel
             ,surveylabelnumber
                 from firstcontact  
     )     
select
fc.studentid            "V1"
,fc.createddate          "V2"
,fc.modifieddate         "V3"
,(select responselabel from firstcontact_res Q13_1 where Q13_1.surveylabelnumber ='Q13_1' and fc.studentid=Q13_1.studentid and fc.createddate=Q13_1.createddate and fc.modifieddate=Q13_1.modifieddate limit 1 ) "Q13_1"
,(select responselabel from firstcontact_res Q65_TEXT where Q65_TEXT.surveylabelnumber ='Q65_TEXT' and fc.studentid=Q65_TEXT.studentid and fc.createddate=Q65_TEXT.createddate and fc.modifieddate=Q65_TEXT.modifieddate limit 1 ) "Q65_TEXT"
from firstcontact_std fc  
;

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群