DarkWorlds
Technical User
Ok this is something very similar to what I am facing, but dumbed down. None of these columns or tables names exist in real life (Very paranoid company I work for, understandable though) but the fundamental problem I am having is like below.
Basically I know I could have done something similar to this is MS SQL (Or am I dreaming?). If I am right or wrong I need to know a way around this.
Obviously if you comment out the "CAL.WEEK_SINCE_2005" and "AND CUST.week_since_2005 = CAL.WEEK_SINCE_2005" it would work. But I really need it to display the date as well
I will be joining other statements to this. I am hoping on doing this in one select statement instead of creating multiple tables as I am now. All the other joined tables will follow a VERY similar layout to this.
I look forward to learning what I did wrong and how I can fix it.
select ORG.ORGANIZATION_NAME,
CUST.CUST_COUNT,
CAL.WEEK_SINCE_2005
FROM organization ORG,
calendar CAL
LEFT JOIN (
SELECT CAP.CURRENT_STORE,
CALEN.week_since_2005,
count(CAP.inactive_date) CUST_COUNT
FROM CUST_AGREE_PAST CAP,
calendar CALEN
WHERE CAP.active_date is not null
and CAP.inactive_code in ('T')
and CAP.inactive_date between '01-sep-07' and sysdate
and CAP.INACTIVE_DATE = CALEN.CALENDAR_DATE
and CAP.RSN_CODE_ID in (select rsn_code_id from reasons where title in ('FAIL', 'NO CALL'))
GROUP BY CAP.CURRENT_STORE,
CALEN.week_since_2005) CUST
ON PO.CURRENT_STORE = ORG.ORGANIZATION_NAME
AND CUST.week_since_2005 = CAL.WEEK_SINCE_2005
Basically I know I could have done something similar to this is MS SQL (Or am I dreaming?). If I am right or wrong I need to know a way around this.
Obviously if you comment out the "CAL.WEEK_SINCE_2005" and "AND CUST.week_since_2005 = CAL.WEEK_SINCE_2005" it would work. But I really need it to display the date as well
I will be joining other statements to this. I am hoping on doing this in one select statement instead of creating multiple tables as I am now. All the other joined tables will follow a VERY similar layout to this.
I look forward to learning what I did wrong and how I can fix it.
select ORG.ORGANIZATION_NAME,
CUST.CUST_COUNT,
CAL.WEEK_SINCE_2005
FROM organization ORG,
calendar CAL
LEFT JOIN (
SELECT CAP.CURRENT_STORE,
CALEN.week_since_2005,
count(CAP.inactive_date) CUST_COUNT
FROM CUST_AGREE_PAST CAP,
calendar CALEN
WHERE CAP.active_date is not null
and CAP.inactive_code in ('T')
and CAP.inactive_date between '01-sep-07' and sysdate
and CAP.INACTIVE_DATE = CALEN.CALENDAR_DATE
and CAP.RSN_CODE_ID in (select rsn_code_id from reasons where title in ('FAIL', 'NO CALL'))
GROUP BY CAP.CURRENT_STORE,
CALEN.week_since_2005) CUST
ON PO.CURRENT_STORE = ORG.ORGANIZATION_NAME
AND CUST.week_since_2005 = CAL.WEEK_SINCE_2005