Project

General

Profile

sql_eco_rep.txt

latest one - Abdelhalim Abu Qamar, 04/11/2019 04:25 PM

Download (763 Bytes)

 
1
SELECT --COUNT (RESULT_ID)
2
  COUNT(
3
  CASE
4
    WHEN RESULT_ID IN (1,3,6)
5
    THEN 'مستوفي '
6
    ELSE NULL
7
  END ) mostwfii ,
8
  COUNT(
9
  CASE
10
    WHEN RESULT_ID IN (2,4,5,7)
11
    THEN 'مخالف '
12
    ELSE NULL
13
  END ) mokhlaf ,
14
  cwi_get_pkg.get_main_activity_sector_desc ( Ins_Pkg.GET_order_licn( vdtl.ORDER_ID ) ) lincc_eco
15
  -- vdtl.VISIT_ID
16
FROM INS_VISIT_ORDER_DTL vdtl ,
17
  INS_VISIT_ORDER vm
18
WHERE vm.VISIT_ID   = vdtl.VISIT_ID
19
AND vm.VISIT_STATUS =2
20
AND LOCATION_STATUS = 3
21
and VISIT_ID between  :p_from_date to :P_to_Date 
22
AND RESULT_ID      IS NOT NULL
23
AND RESULT_ID      <> -1 -- we have 309 visit null result till 11042019 ;
24
GROUP BY cwi_get_pkg.get_main_activity_sector_desc ( Ins_Pkg.GET_order_licn( vdtl.ORDER_ID ) ) ;