美文网首页
数据分析一

数据分析一

作者: knock | 来源:发表于2022-01-18 11:15 被阅读0次
SELECT
  @i:=@i+1 AS serialNo,
    fasch.school_name,
  CASE
  WHEN fasch.LEVEL = 4  or exists (select * from fo_atte_school_cert fascc  where fascc.school_id=fasch.id and  fascc.cert_type='2')  THEN '示范园' 
    WHEN fasch.LEVEL = 5 THEN '公益园' 
    WHEN fasch.audit_state = '2'  or exists (select * from fo_atte_school_cert fascc  where fascc.school_id=fasch.id and  fascc.cert_type='1')  THEN '足特园' 
    ELSE '普通'  END AS level,
 CASE 
 fasch.type 
 WHEN '0' THEN '公立'
 WHEN '1' THEN '私立'
 ELSE '未知' END  as type,
 fasch.province,
 CASE 
 fasch.status   
 WHEN '88' THEN '已认证'
 ELSE '未认证' END  as status,
   (select count(*) from fo_atte_teacher  fatea where fatea.school_id =fasch.id  and fatea.deletetime is null and fatea.createtime >= 1609430400 and fatea.createtime <= 1640966399)  as countTeacher,
 (select count(*)  from fo_atte_student  fastu where fastu.school_id=fasch.id  and fastu.deletetime is null and fastu.createtime >= 1609430400  and fastu.createtime <= 1640966399)  as registerStudentCount,
 fnrank.study_count as studyCountTotal,
 fnrank.student_test_count as studentTestCountTotal,
-- 获取测试数据数量
(
 IFNULL((SELECT count(*) from fo_testing_log  ftl3  where ftl3.school_id=fasch.id  and  ftl3.type='0' and ftl3.testing_foundation_id=3 and ftl3.createtime >= 1609430400 and ftl3.createtime <= 1640966399 ),0)
 +
IFNULL( (SELECT count(*) from fo_testing_log  ftl1 where ftl1.school_id=fasch.id  and  ftl1.type='0' and ftl1.createtime >= 1609430400 and ftl1.createtime <= 1640966399) ,0)
 +
 IFNULL((SELECT count(*) from fo_testing_log  ftl2 where ftl2.school_id=fasch.id  and  ftl2.type='1' and ftl2.createtime >= 1609430400 and ftl2.createtime <= 1640966399 ),0) * 2
 +
 IFNULL((SELECT count(*) from fo_testing_log  ftl2 where ftl2.school_id=fasch.id  and  ftl2.type='1' and  ftl2.testing_sports_id in (4,15,16) and  ftl2.createtime >= 1609430400 and ftl2.createtime <= 1640966399 ),0) * 2
 ) as testCount,
 -- 测试数据有效数量 
(
 IFNULL((SELECT count(*) from fo_testing_log  ftl3  where ftl3.school_id=fasch.id  and  ftl3.type='0' and ftl3.testing_foundation_id=3 and ftl3.createtime >= 1609430400 and ftl3.createtime <= 1640966399 ),0)
 +
IFNULL( (SELECT count(*) from fo_testing_log  ftl1 where ftl1.school_id=fasch.id  and  ftl1.type='0' and ftl1.createtime >= 1609430400 and ftl1.createtime <= 1640966399) ,0)
 +
 IFNULL((SELECT count(*) from fo_testing_log  ftl2 where ftl2.school_id=fasch.id  and  ftl2.type='1' and ftl2.createtime >= 1609430400 and ftl2.createtime <= 1640966399 ),0) 
 +
 IFNULL((SELECT count(*) from fo_testing_log  ftl2 where ftl2.school_id=fasch.id  and  ftl2.type='1' and  ftl2.testing_sports_id in (4,15,16) and  ftl2.createtime >= 1609430400 and ftl2.createtime <= 1640966399 ),0) 
 ) as validTestCount,
 -- 学校总积分
  (
    IFNULL(fasch.integral,0) 
    +
    IFNULL( (SELECT  sum(fusl.score) from  fo_user_score_log  fusl INNER join  fo_atte_teacher fatea  on fusl.user_id=fatea.user_id 
  where  fatea.school_id =fasch.id and fusl.createtime >= 1609430400 and fusl.createtime <= 1640966399 and fusl.role='2') ,0)
  +
    IFNULL( (SELECT  sum(fusl.score) from  fo_user_score_log  fusl INNER join  fo_atte_student fatea  on fusl.user_id=fatea.id 
where  fatea.school_id =fasch.id and fusl.createtime >= 1609430400 and fusl.createtime <= 1640966399 and fusl.role='3'),0)
    ) as totalIntergral, 
 IFNULL(fasch.integral,0) as schoolIntegral,
 
 IFNULL( (SELECT  sum(fusl.score) from  fo_user_score_log  fusl INNER join  fo_atte_teacher fatea  on fusl.user_id=fatea.user_id 
where  fatea.school_id =fasch.id and fusl.createtime >= 1609430400 and fusl.createtime <= 1640966399 and fusl.role='2') ,0) as teacherIntegral,

 IFNULL( (SELECT  sum(fusl.score) from  fo_user_score_log  fusl INNER join  fo_atte_student fatea  on fusl.user_id=fatea.id 
where  fatea.school_id =fasch.id and fusl.createtime >= 1609430400 and fusl.createtime <= 1640966399 and fusl.role='3'),0) as studentIntegral

FROM fo_atte_school fasch
LEFT JOIN fo_new_ranking fnrank ON fasch.id = fnrank.school_id 
left join tmp_valid_test_count tvtc on tvtc.school_id=fasch.id,
(SELECT @i:=0)serial
where  fasch.createtime <= 1640966399 

相关文章

  • 数据分析方法

    一、数据分析分类:描述性数据分析、探索性数据分析、验证性数据分析。 1、描述性数据分析:1)对比分析;2)平均分析...

  • 商务数据分析与应用学习笔记-数据分析的工作流程

    一、数据分析工作流程分析 1、数据分析的一般工作流程 明确目标-规划框架-数据获取-数据分析-数据分析-总结评估 ...

  • 20190812SPSS学习心得(一)

    一、数据分析归类 结构化数据分析和测量数据分析 二、数据分析应用领域归类 小样本:小数据分析,用加号连接,市场...

  • 一图知晓数据分析与数据挖掘的区别是什么?

    数据分析可以分为广义的数据分析和狭义的数据分析,广义的数据分析就包括狭义的数据分析和数据挖掘,我们常说的数据分析就...

  • 数据挖掘和分析的区别

    数据分析可以分为广义的数据分析和狭义的数据分析,广义的数据分析就包括狭义的数据分析和数据挖掘,我们常说的数据分析就...

  • 一图知晓数据分析与数据挖掘的区别是什么?

    数据分析可以分为广义的数据分析和狭义的数据分析,广义的数据分析就包括狭义的数据分析和数据挖掘,我们常说的数据分析就...

  • 数据分析与数据挖掘的区别是什么?

    数据分析可以分为广义的数据分析和狭义的数据分析,广义的数据分析就包括狭义的数据分析和数据挖掘,我们常说的数据分析就...

  • 数据分析入门

    一:入门介绍 #统计学:将数据分析划分为 描述性数据分析(初级)、探索性数据分析、验证性数据分析# #数据分析在企...

  • 数据分析的六步法是什么?

    数据分析一般涉及6个步骤:设定目标、数据发掘、数据监控、数据处理、数据分析、数据总结。 一、设定目标 数据分析启动...

  • 小菜鸟偷学数据分析(一)

    1.1数据分析是神马? 1.1.1何谓数据分析 数据分析就是对数据进行分析,较为专业的说法,数据分析是指用适当...

网友评论

      本文标题:数据分析一

      本文链接:https://www.haomeiwen.com/subject/ghrkhrtx.html