报表有点复杂_第1页
免费预览已结束,剩余2页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、报表有点复杂declare begin_ date, end_date datetime begin_date =:begin_date set end_date =:end_date set begin_date=convert(varchar(10),begin_date,120) + 00:00:00 set end_date=convert(varchar(10),end_date,120) + 23:59:59 select visit_dept,convert(varchar(10),visit_date,120) date,name,clinic_type into visit_

2、table from mz_visit_table where date(mi,mz_visit_table.visit_date ,begin_date ) =0 and datiff(mi, mz_visit_table.visit_date , end_date ) =0 group by visit_dept,convert(varchar(10),visit_date,120),name,clinic_type select m(a) a,sum(b) b,sum(c) c,sum(d) d,sum(e) e,sum(f) f,sum(g) g,sum(h) h,sum(i) i,s

3、um(j) j,sum(k) k ,sum(m) m,sum(l) l,sum(n) n ,sum(o) o,sum(p) p ,sum(q) q from(select (select count(*) from visit_table a where a.visit_dept in ( 1010100 , 1010101 , 1010200 , 1010201 , 1010300 , 1010301 , 1010500 , 1010501 , 1010600 , 1010601 , 1010400 , 1010401 , 1010700 , 1010701 ) and isnull(cli

4、nic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 ) )a , (select count(*) from visit_table a where a.visit_dept in ( 1020100 , 1020101 , 1020300 , 1020301 , 1020500 , 1020501 , 1020400 , 1020401 , 1020600 , 1020601 , 1020700 , 1020701 , 1020800 , 1020801 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11

5、 , 14 ) )b, (select count(*) from visit_table a where a.visit_dept in ( 1040000 , 1040001 , 1030000 , 1030001 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 ) )c, (select count(*) from visit_table a where a.visit_dept in ( 1060300 , 1060301 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06

6、, 11 , 14 )d, (select count(*) from visit_table a where a.visit_dept in ( 1050000 , 1050001 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )e, (select count(*) from visit_table a where a.visit_dept in ( 1010900 , 1010901 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )f, (selec

7、t count(*) from visit_table a where a.visit_dept in ( 1070000 , 1070001 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )g, (select count(*) from visit_table a where a.visit_dept in ( 1060200 , 1060201 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )h, (select count(*) from visi

8、t_table a where a.visit_dept in ( 1080000 , 1080001 , 1010800 , 1010801 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )i, (select count(*) from visit_table a where a.visit_dept in ( 1120000 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )j, (select count(*) from visit_table a

9、where a.visit_dept in ( 1060100 , 1060101 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )o, (select count(*) from visit_table a where a.visit_dept not in ( 1010100 , 1010101 , 1010200 , 1010201 , 1010300 , 1010301 , 1010500 , 1010501 , 1010600 , 1010601 , 1010400 , 1010401 , 1010700 , 10

10、10701 , 1020100 , 1020101 , 1020300 , 1020301 , 1020500 , 1020501 , 1020400 , 1020401 , 1020600 , 1020601 , 1020700 , 1020701 , 1020800 , 1020801 , 1040000 , 1040001 , 1030000 , 1030001 , 1060300 , 1060301 , 1050000 , 1050001 , 1010900 , 1010901 , 1070000 , 1070001 , 1060200 , 1060201 , 1080000 , 10

11、80001 , 1010800 , 1010801 , 1120000 , 1060100 , 1060101 )and isnull(clinic_type, 01 ) in ( 01 , 05 , 06 , 11 , 14 )q, 0 k, 0 m, 0 l, 0 n, 0 p union all select 0,0,0,0,0,0,0,0,0,0,0,0, (select count(*) from visit_table a where isnull(clinic_type, 01 ) in( 03 , 04 , 07 , 08 , 09 , 10 ) k, (select count(*) from visit_table a where isnull(clinic_type, 01 ) in( 12 )m, (select count(*) from visit_table a where isnull(clinic_type

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论