hello world!!!!!

写下自己的一些心得,写下自己问题的方式,写下程序之路的艰辛,希望能够有朝一日成为大牛。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

解决如何连续包两层不能关联主键的情况。

Posted on 2016-06-15 15:58  陈力  阅读(123)  评论(0编辑  收藏  举报
select a.*, b.*
  from (select count(1) as numberIll, features_level, sample_inspection_id
          from (SELECT i.features_level,
                       i.features,
                       i.sample_inspection_id,
                       T.BASEAMINE_ID,
                       T.COLUMN_NAME,
                       V.COLUMN_VALUE,
                       V.DETAIL_ID,
                       
                       (case
                         when i.features = '计数' AND V.COLUMN_VALUE = 'NG' then
                          0
                         when (i.features = '计量' AND V.COLUMN_VALUE <> '-') and
                              (to_number(V.COLUMN_VALUE) > i.offset_value_up or
                              to_number(V.COLUMN_VALUE) <= i.offset_value_low) then
                          0
                         else
                          1
                       end) as illLegal
                
                  FROM OQC_BASE_STANDRAD_TITLE    T,
                       OQC_BASE_STANDRAD_VALUE    V,
                       oqc_inspection_sample_item i
                 WHERE T.ID = V.COLUMN_ID
                   and T.STATE = 'A'
                   AND T.BASEAMINE_ID in
                       (select a.id
                  from OQC_INSPECTION_SAMPLE a
                 where a.org_id = 200267 and a.is_v2='1' and state='A' AND A.STATUS='已检验')
                   and t.is_insepection_result = '1'
                   and v.detail_id = i.id)
         where illLegal = 0
         group by features_level, sample_inspection_id) a,
       OQC_INSPECTION_SAMPLE b
 where a.sample_inspection_id = b.id