学生最后一次沟通内容

####主题:学生最后一次沟通内容
####执行时间1000s,shape:(397,4),新脱敏库
####日期:2019-03-21
####需求方:朱枫
####输出方式:excel
####create by:汪国强
####update by:
####checked by:
SELECT
        s.student_no 学生编号,
        s.exam_year 高考年份,
        a.smax 最后一次沟通时间,
        a.content 沟通内容
FROM
        view_student s
LEFT JOIN
        (SELECT
            *
        FROM
            (SELECT
                student_intention_id,
                end_time,
                content
             FROM
                view_communication_record
             ORDER BY 2 DESC) b 
        GROUP BY student_intention_id) a ON a.student_intention_id = s.student_intention_id
WHERE
        s.student_no in ()
############### 吉莹莹改进仅1s ######################
SELECT
        s.student_no 学生编号,
        s.exam_year 高考年份,
        (SELECT
             content
         FROM
             view_communication_record 
         WHERE
             student_intention_id = s.student_intention_id
         ORDER BY
              end_time DESC LIMIT 1) 最后一次沟通内容
FROM
        view_student s
WHERE
        s.student_no in ()
文档更新时间: 2019-03-29 11:14   作者:admin