How To Combine These 2 Queries into 1 Query ?
Results 1 to 2 of 2

Thread: How To Combine These 2 Queries into 1 Query ?

  1. #1
    Join Date
    Jun 2012
    Posts
    1

    How To Combine These 2 Queries into 1 Query ?

    Code:
    SELECT b.KPCNO
             ,b.KPC_FULL_NAME
             ,min(c.time) in_time
    
           FROM xxkpc_hr_personnel_v2  b
                   ,xxkpc_fingerscan_data_v c 
           WHERE to_char(c.userpin(+)) = b.KPCNO 
           AND b.type(+) = 'KPC Employee'
           AND b.DESIGNATION is null
           AND b.kpcno IS NOT NULL
           AND to_char(c.trdate(+),'DD-MON-YYYY') = to_char(SYSDATE,'DD-MON-YYYY')
           AND c.tr_type(+) = 'Admitted In'
           AND c.unitno(+) not in ('Staff Exit Barrier','Staff Entry Barrier 1','Service Gate Entry Barrier','Staff Entry Barrier 2')
    
          AND b.ORGANIZATION_ID=(select g.ORGANIZATION_ID from  xxkpc_fn_web_personnel_v g where g.kpcno = :kpcno)
               GROUP BY b.KPCNO
              ,b.kpc_full_name
    
    
                  UNION
    
    
    
    
     SELECT b.KPCNO
             ,b.KPC_FULL_NAME
             ,min(c.time) in_time
    
           FROM xxkpc_hr_pos_struct_code_comb   a
                   ,xxkpc_hr_personnel_v2  b
                   ,xxkpc_fingerscan_data_v 
           WHERE b.position_id(+) = a.child_position_id
           AND to_char(c.userpin(+)) = b.KPCNO  
           AND b.type(+) = 'KPC Employee'
           AND b.kpcno IS NOT NULL
           AND to_char(c.trdate(+),'DD-MON-YYYY') = to_char(SYSDATE,'DD-MON-YYYY')
           AND c.tr_type(+) = 'Admitted In'
           AND c.unitno(+) not in ('Staff Exit Barrier','Staff Entry Barrier 1','Service Gate Entry Barrier','Staff Entry Barrier 2')
           AND a.PERANT_POSITION_ID =  (select g.POSITION_ID from  xxkpc_fn_web_personnel_v g where g.kpcno = :kpcno)
    
               GROUP BY b.KPCNO
              ,b.kpc_full_name

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,898

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •