课时统计开发过程sql使用记录

/*
//消费时长统计
select sum(duration) as totalDuration, sum(count) as number, date
      from statistics_duration_cu
      where school_id="test" and date >= "2014-9-28" and date <= "2014-10-17"
      group by date
      order by date ASC
*/

/*
SELECT sd.user_id AS userId,sd.school_id AS schoolId,sd.course_id AS courseId, sd.lecture_id AS lecture_id, sum(sd.duration) AS totalDuration, sum(sd.count) AS number,sd.date AS date
		from statistics_duration_cu as sd 

		where sd.school_id="swiftv"
		 GROUP BY sd.date order by sd.date DESC;
*/

/*
SELECT sd.user_id AS userId,sd.school_id AS schoolId,sd.course_id AS courseId, sd.lecture_id AS lecture_id, sum(sd.duration) AS totalDuration, sum(sd.count) AS number,sd.date AS date, cu.title AS courseTitle
		from statistics_duration_cu as sd
		 LEFT JOIN course as cu on cu.course_id=sd.course_id   

		where sd.user_id="httirtd2" and sd.school_id="test"
		 GROUP BY sd.course_id order by totalDuration DESC;

*/

/*
//查询该网校的所有学员的学习情况  COUNT
 SELECT count(*) from
		(SELECT sd.user_id
		from statistics_duration_cu as sd
		where sd.school_id="swiftv"
		 GROUP BY sd.user_id
		)as temp;
*/

/*
//查询该网校的所有学员的学习情况
SELECT sd.user_id AS userId,sd.school_id AS schoolId,sd.course_id AS courseId, sum(sd.duration) AS totalDuration, sum(sd.count) AS number,sd.date AS date, u.nickname AS nickname
		from statistics_duration_cu as sd
		 LEFT JOIN user as u on u.user_id=sd.user_id  

		where sd.school_id="swiftv"
		 GROUP BY sd.user_id order by totalDuration DESC;
*/

/*
SELECT sd.user_id AS userId,sd.school_id AS schoolId,sd.course_id AS courseId,sd.lecture_id As lectureId, section_title AS sectionTitle,lecture_title As lectureTitle,sum(sd.duration) AS totalDuration, sum(sd.count) AS number,sd.date
				from statistics_duration_cu as sd
				where sd.course_id="hxbazkq4" and sd.school_id="swiftv" and sd.date BETWEEN '2014-9-28' AND '2014-10-13'
				GROUP BY sd.date order by sd.date DESC
*/

/*
//
SELECT count(*) from
			 (SELECT sd.lecture_id
				from statistics_duration_cu as sd
				where sd.course_id="hyjgz2np" and sd.school_id="test" and user_id="httirtd2"
				 GROUP BY lecture_id
			 ) as temp;
*/

/*
//学生针对一门课程的时长  (count) 用于分页
SELECT count(*) from
 (SELECT sd.user_id
			from statistics_duration_cu as sd 

			where sd.course_id="hyjgz2np" and sd.school_id="test"
			GROUP BY sd.user_id
) as temp;
*/

/*
//所有课程分组后的记录数
SELECT count(*) from
(SELECT sd.course_id
from statistics_duration_cu as sd
where sd.school_id="swiftv"
 GROUP BY sd.course_id
)as temp;
*/

/*
//管理后台-详情 by 时间
SELECT sd.school_id,sd.course_id AS courseId,sum(sd.duration) AS duration, sum(sd.count) AS number,sd.date AS date, cu.title AS courseTitle
from statistics_duration_cu as sd
 LEFT JOIN course as cu on cu.course_id=sd.course_id 

where sd.school_id="test" and sd.date BETWEEN '2014-9-28' AND '2014-10-10'
 GROUP BY sd.course_id ORDER BY sd.date ASC;
*/

/*
//管理后台-详情
SELECT sd.school_id,sd.course_id AS courseId,sd.lecture_id AS lectureId, lecture_title AS lectureTitle,sum(sd.duration) AS totalDuration, sum(sd.count) AS number,sd.date AS date
from statistics_duration_cu as sd 

where sd.school_id="test" and sd.course_id="hyjgz2np"
  GROUP BY lectureId ORDER BY totalDuration DESC;
*/

/*
//查询该网校的所有课程的时长统计
SELECT sd.school_id,sd.course_id,sum(sd.duration) AS duration, sum(sd.count) AS number,sd.date AS date, cu.title AS courseTitle
from statistics_duration_cu as sd
 LEFT JOIN course as cu on cu.course_id=sd.course_id 

where sd.school_id="swiftv"
 GROUP BY course_id ORDER BY sd.duration DESC;
*/

/*
//查询一段时间内的统计数据
 SELECT sd.user_id AS userId,sd.school_id AS schoolId,sd.course_id AS courseId,sd.lecture_id As lectureId, section_title AS sectionTitle,lecture_title As lectureTitle,sum(sd.duration) AS totalDuration, sum(sd.count) AS number,sd.date
				from statistics_duration_cu as sd  

				where sd.course_id="i0cpf4a8" and sd.school_id='swiftv' and sd.date BETWEEN '2014-9-1' AND '2014-10-5'
				GROUP BY sd.date;
*/	

/*
select DATE_FORMAT(date,'%Y-%m-%d') as day, school_id AS schoolId, course_id AS courseId, sum(duration) AS totalDuration, sum(count) AS number, date from statistics_duration_cu
where school_id='swiftv' and course_id='hwcuol4d'
 and DATE_FORMAT(date,'%Y')=2014 and DATE_FORMAT(date,'%m')=9 group by day order by day;
*/

/*
SELECT sd.user_id,sd.school_id,sd.course_id,sd.lecture_id, section_title,lecture_title,sum(sd.duration) AS duration, sum(sd.count) AS number,sd.date
from statistics_duration_cu as sd 

where sd.course_id="hwcuol4d" and sd.school_id="swiftv"
GROUP BY date;
*/

/*

select DATE_FORMAT(date,'%Y-%m-%d') as day, sum(duration) from statistics_duration_cu
where school_id='swiftv' and DATE_FORMAT(date,'%Y')=2014 and DATE_FORMAT(date,'%m')=10 group by day order by day;
*/

/*
SELECT sd.user_id,sd.school_id,sd.course_id,sd.lecture_id, section_title,lecture_title,sum(sd.duration) AS duration, sum(sd.count) AS number,sd.date
from statistics_duration_cu as sd 

where sd.course_id="hwcuol4d" and sd.school_id="swiftv"
GROUP BY date  ORDER BY duration DESC;
*/

/*
SELECT sd.user_id,sd.school_id,sd.course_id,sd.lecture_id, section_title,lecture_title,sum(sd.duration) AS duration, sum(sd.count) AS number,sd.date
from statistics_duration_cu as sd 

where sd.course_id="hwcuol4d" and user_id="hz6tvah8" and sd.school_id="swiftv"
 GROUP BY lecture_id ORDER BY sd.duration DESC;
*/

/*
SELECT sd.user_id,sd.school_id,sd.course_id,sd.lecture_id, section_title,lecture_title,sd.duration AS duration, sd.count AS number,sd.date
from statistics_duration_cu as sd 

where sd.course_id="hwcuol4d" and user_id="hz6tvah8" and sd.school_id="swiftv"
  ORDER BY sd.duration DESC;
*/

/*
SELECT sd.user_id,sd.school_id,sd.course_id,sd.lecture_id, sum(sd.duration) AS duration, sum(sd.count) AS number,sd.date,us.nickname,us.avatar
from statistics_duration_cu as sd
LEFT JOIN user as us on sd.user_id=us.user_id
where sd.course_id="hwlrt694" and sd.school_id="swiftv"
GROUP BY sd.user_id ORDER BY sd.duration DESC;
*/

/*
SELECT sd.user_id,sd.school_id,sd.course_id,sd.lecture_id, sum(sd.duration) AS duration, sum(sd.count) AS number,sd.date,us.nickname,us.avatar
from statistics_duration_cu as sd
LEFT JOIN user as us on sd.user_id=us.user_id
where sd.course_id="hwlrt694" and sd.school_id="swiftv"
GROUP BY sd.user_id;
*/

/*
select user_id,course_id,school_id,lecture_id,sum(duration),count(pid) from statistics_duration where user_id="hz1agerm" and course_id="hxbazkq4" and school_id="swiftv";
*/

/*
select * from statistics_duration where course_id="hxbazkq4" and school_id="swiftv";
*/

时间: 2024-10-31 18:41:46

课时统计开发过程sql使用记录的相关文章

SQL Server 记录(更新中...)

sys.databases 显示所有数据库信息 sys.tables 显示当前数据库所有的表的信息 Go 向 SQL Server 实用工具发出一批 Transact-SQL 语句已结束的信号,Go本身不是T-SQL语句 sq_addrole 等等 SQL Server 系统存储过程以字符 sp_ 开头. EXEC或EXECUTE 执行 Transact-SQL 批处理中的命令字符串.字符串或执行下列模块之一:系统存储过程.用户定义存储过程.CLR 存储过程.标量值用户定义函数或扩展存储过程.

--投资情况统计详情sql

--投资情况统计详情sqlselect BidRecord.*, RegInfo.UserName,UserInfo.phone,BorrowInfo.Title,BorrowInfo.BorrowCode from--(select * from [YYD_Account_MoneyRecord] where moneytype='参与投标' and state=1) as MoneyRecord(select * from YYD_Borrow_BidRecord where status=

Yii2如何添加sql日志记录的配置信息

在使用Yii2框架的时候,常常会出现没有sql日志记录的问题.在代码里一句一句的打印sql语句也不现实.所以就要用文件记录起来. 在 config/web.php 里面的 log配置中增加如下配置 [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning','info'], 'logVars'=>[], //表示以yii\db\或者app\models\开头的分类都会写入这个文件 'categories'=>

电Call记录统计查询sql

DECLARE @startTime datetimeset @startTime='2016-07-12' SELECT * FROM (--坐席号/电话个数/通话总时长select zuoxi as zuoxi1,COUNT(1) as PhoneCount,SUM(DATEDIFF(ss,jtDate,endDate)) PhoneCountSC from HUR_TelCallRecord where vdef2=1 and--Convert(varchar(10),jtDate,120

常用SQL脚本记录一

20.SUM()和 列+ 统计结果时:如果列里有一行为null,SUM函数会忽略它:如果+,则结果集也为NULL了 19 SUBSTRING (expression,startIndex, endIndex) SELECT SUBSTRING ('Los Angeles',1, 3) 返回结果Los,默认索引从1开始 18 SQL分隔字符串函数返回一个table数据集 ,拆成结果集SELECT * FROM dbo.fn_split('A,B,CD,EFG,H',',')Table里"-&quo

常用sql 全记录(添加中)

-- 数据库SQL总结中........... --SQL分类: (CREATE,ALTER,DROP,DECLARE) ---DDL-数据定义语言(SELECT,DELETE,UPDATE,INSERT) ---DML-数据操纵语言(GRANT,REVOKE,COMMIT,ROLLBACK) --DCL-数据控制语言--设置内存选项--设置 min server memory 配置项EXEC sp_configure N'min server memory (MB)', 0 --设置 max

一个统计报表sql问题

今天朋友问我了一个统计报表的sql问题.我弄了好久.终于算是写出来了.这里记录下. 问题: id--------------name--------------addtime1                       a                      2014-01-01 02:30:211                       b                      2014-01-03 03:20:021                       c      

Spark SQL学习记录

HDFS YARN YARN架构:1个RM(ResourceManager)主节点+N个NM(NodeManager)从节点ResourceManager职责:一个集群active状态的RM只有一个,负责整个集群额资源管理和调度1.处理客户端的请求(启动或杀死一个作业)2.启动/监控ApplicationMaster(一个作业对应一个AM)3.通过心跳监控NM4.系统的资源分配和调度 NodeManager职责:整个集群中有N个节点,负责单个节点的资源管理和使用以及task的运行1.定期向RM汇

SQL 练习记录

--1. 统计订单金额累计>=10000的用户 最近的5笔交易记录 select * from (select t1.ID, t1.[Money], t1.InitialTime, t1.[User], u1.Name,u1.Mobile, row_number() over(partition by t1.[User] order by t1.InitialTime desc) as num from [TradeFictitious] t1join(select [User] from Tr