I am building a query that will build one, pretty large data set based on 4 tables. Here is my query so far:
SELECT
CLIENT_CA."Requisition_ID",
CLIENT_REQS."Requisition Title",
CLIENT_REQS."Country",
CLIENT_CD."Application_Status",
CLIENT_CA."Candidate",
CLIENT_CD."Gender",
max(case when
CLIENT_CA."Process_of_Activity" = 'Application Entry' then
CLIENT_CA."Completed_on" end) as "ENTRY",
max(case when
CLIENT_CA."Process_of_Activity" = 'Candidate Selection' then
CLIENT_CA."Completed_on" end) as "Selection",
max(case when
CLIENT_CA."Process_of_Activity" = 'Job Offer' then
CLIENT_CA."Completed_on" end) as "Offer",
CLIENT_RR."Status_Reason(E-Rec)"
FROM CLIENT_CA
LEFT JOIN CLIENT_CD ON (CLIENT_CA."Candidate_ID"=CLIENT_CD."Candidate_ID"
and CLIENT_CA."Requisition_ID"=CLIENT_CD."Requisition_ID" )
LEFT JOIN CLIENT_REQS ON CLIENT_REQS."Requisition_ID"=CLIENT_CA."Requisition_ID"
LEFT JOIN CLIENT_RR
ON (CLIENT_CA."Candidate_ID"=CLIENT_RR."Candidate_ID" and CLIENT_CA."Requisition_ID"=CLIENT_RR."Requisition_ID" )
GROUP BY CLIENT_CA."Candidate"
,CLIENT_CA."Requisition_ID"
,CLIENT_CD."Gender"
,CLIENT_REQS."Requisition Title"
,CLIENT_REQS."Country"
,CLIENT_RR."Status_Reason(E-Rec)"
,CLIENT_CD."Application_Status";
technically this query works just fine and gives me exactly what I need with no errors. The thing is that I will need to add some 80 columns to the SELECT clause and the system or rather the logic is forcing me to put every column I add in there to also put it in the GROUP BY clause... I guess that's because of the "max" function. Basically CLIENT_CA is my "base" table and I am trying to achieve what in MS Excel would be done by the VLOOKUP function on the other 3 tables. I'm just a bit concerned that I am making this a bit unnecessarily complicated. Please do not hesitate to tell me I'm just plain stupid :) but only IF you have a suggestion how to do this better :) Thank you. oh.... I'm running this on dashDB.