Crystalguru
Technical User
I am having trouble with the following query NOT doing the division...
SELECT
c.PROPERTY_REGION
,c.property_id as property_id
, max(C.PROPERTY_EFF_DATE) as prop_eff_dt
, max(C.PROPERTY_EXP_DATE) as prop_exp_dt
, to_char(TS.DATE_DAY,'MM') as Date_Month
, to_char(TS.DATE_DAY,'YYYY') as Date_Year
, sum(TS.CANCELS) as cancels
, sum(TS.DENIES) as denies
, sum(TS.GUEST_TRAFFIC) as guest_traffic
, sum(TS.NEW_LEASES) as new_leases
, case when sum(TS.GUEST_TRAFFIC)=0 then 0 else
sum(TS.NEW_LEASES)-(sum(TS.CANCELS)+
sum(TS.DENIES))/sum(TS.GUEST_TRAFFIC)end as closing_ratio
FROM
COMMUNITIES C,
TIME_SERIES_BY_UNIT_TYPE TS
WHERE
C.PROPERTY_ID = TS.PROPERTY_ID AND
C.PROPERTY_REGION = 'Atlanta'
group BY
C.PROPERTY_REGION
,to_char(TS.DATE_DAY,'MM')
,to_char(TS.DATE_DAY,'YYYY')
,c.property_id
The results are giving me the New_Lease total when the cancel+denies is 0.
For example:
Cancel Denies New_leases Traffic Closing_ratio
0 0 7 25 7
It should be:
0 0 7 25 0.28
thanks
SELECT
c.PROPERTY_REGION
,c.property_id as property_id
, max(C.PROPERTY_EFF_DATE) as prop_eff_dt
, max(C.PROPERTY_EXP_DATE) as prop_exp_dt
, to_char(TS.DATE_DAY,'MM') as Date_Month
, to_char(TS.DATE_DAY,'YYYY') as Date_Year
, sum(TS.CANCELS) as cancels
, sum(TS.DENIES) as denies
, sum(TS.GUEST_TRAFFIC) as guest_traffic
, sum(TS.NEW_LEASES) as new_leases
, case when sum(TS.GUEST_TRAFFIC)=0 then 0 else
sum(TS.NEW_LEASES)-(sum(TS.CANCELS)+
sum(TS.DENIES))/sum(TS.GUEST_TRAFFIC)end as closing_ratio
FROM
COMMUNITIES C,
TIME_SERIES_BY_UNIT_TYPE TS
WHERE
C.PROPERTY_ID = TS.PROPERTY_ID AND
C.PROPERTY_REGION = 'Atlanta'
group BY
C.PROPERTY_REGION
,to_char(TS.DATE_DAY,'MM')
,to_char(TS.DATE_DAY,'YYYY')
,c.property_id
The results are giving me the New_Lease total when the cancel+denies is 0.
For example:
Cancel Denies New_leases Traffic Closing_ratio
0 0 7 25 7
It should be:
0 0 7 25 0.28
thanks