请教一个统计查询如何用模型来完成

浏览:517 发布日期:2014/09/01 分类:求助交流 关键字: 查询 统计 模型
数据库:ORACLE
查询语句:select b.id,
       b.ios,
       b.dept,
       b.ward,
       c.beds,
       count(a.patient_id) used
  from pats_in_hospital a,
       (select substr(a.dept_code, 3, 6) id,
               decode(a.internal_or_sergery, 0, '内科', 1, '外科') ios,
               b.dept_name dept,
               a.dept_name ward
          from dept_dict a,
               (select dept_code, dept_name
                  from dept_dict
                 where length(trim(dept_code)) = 4) b
         where substr(a.dept_code, 3, 4) = b.dept_code) b,
       (select dept_code, count(*) beds from bed_rec group by dept_code) c
 where b.id = a.dept_code
   and c.dept_code = a.dept_code
 group by b.id, b.ios, b.dept,b.ward, c.beds
 order by id;
求教模型的实现,
最佳答案
评论( 相关
后面还有条评论,点击查看>>