From 81ce3cc7d203ae8724d6f6cc12a56eb3ce60b321 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 13 Mar 2020 20:57:09 +0800 Subject: [PATCH] =?UTF-8?q?sql=E9=A2=84=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sql_review.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/tasks/sql_review.rake diff --git a/lib/tasks/sql_review.rake b/lib/tasks/sql_review.rake new file mode 100644 index 000000000..761e6be60 --- /dev/null +++ b/lib/tasks/sql_review.rake @@ -0,0 +1,19 @@ +# 西部地区学校总数 +# select distinct(s.province), s.name from user_extensions ue, schools s where ue.school_id=s.id and s.province in ('四川','重庆','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆广西','内蒙古') +# +# 西部地区 +# select count(*) from courses where school_id in (select distinct(s.id) from user_extensions ue, schools s where ue.school_id=s.id and s.province in ('四川','重庆','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆广西','内蒙古') group by s.name) +# 用课门次=课程总数*45*12 +# +# 西部学习总人数 +# select count(*) from user_extensions ue where ue.school_id in (select id from schools s where s.province in ('四川','重庆','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆广西','内蒙古') group by s.name) +# 学习人次=西部实际学习总人数/平台实际用户总数 * 平台总学习人次 +# +# select distinct(s.province), s.name from user_extensions ue, schools s where ue.school_id=s.id and ue.location in ('四川','重庆','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆广西','内蒙古') +# +# select distinct(id) from courses where school_id in (select distinct(school_id) from user_extensions where location in ('四川','重庆','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆广西','内蒙古')) +# +# select count(*) from course_members where course_id in (select distinct(id) from courses where school_id in (select distinct(school_id) from user_extensions where location in ('四川','重庆','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆广西','内蒙古'))) +# +# # 西部地区学习人数 +# select count(*) from user_extensions where location in ('四川','重庆','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆广西','内蒙古') \ No newline at end of file