1.sql统计语句

Posted IT菜鸟作家

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1.sql统计语句相关的知识,希望对你有一定的参考价值。

select exam_item_code, exam_item, EXAMDATE, count(distinct patient_id)
from (select t2.exam_item_code,
t2.exam_item,
to_char(t1.exam_date_time, ‘yyyy-mm‘) as EXAMDATE,
t1.patient_id
from exam.exam_master t1, exam.exam_items t2
where t1.exam_no = t2.exam_no
and exam_date_time >=
to_date(‘2014-07-01 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)
and exam_date_time <=
to_date(‘2015-06-30 23:59:59‘, ‘yyyy-mm-dd hh24:mi:ss‘)
and exam_class = ‘CT‘
and performed_by = ‘2401‘
and t2.exam_item_code in
(‘210300110‘, ‘210300111‘, ‘210300109‘, ‘210300108‘,
‘210300036‘, ‘210300037‘, ‘210300134‘, ‘210300125‘,
‘210300069‘, ‘210300070‘, ‘210300071‘, ‘210300080‘,
‘210300115‘)
--and t2.exam_item_code in (‘210300134‘)
)
group by exam_item_code, exam_item, EXAMDATE
order by exam_item_code, exam_item, EXAMDATE desc

以上是关于1.sql统计语句的主要内容,如果未能解决你的问题,请参考以下文章

SQL语句

PLSQL语句编写步骤

工作效率up | 千万级数据库的性能优化秘诀

SQL语句统计每天、每月、每年的销售总额

怎样一条SQL语句统计该年每月的数据个数

while语句基本练习(求和思想,统计思想)