Schaeffrcc
Technical User
I have a database that has many tables and a massive table that links it all together called Case_History. I have been trying for a while to get the correct data out of this history table because of duplication when Client move from here to there and back I have resigned myself to breaking it down into may parts. Below is the code for the First Part, it extracts the DISTINCT Case_Seq that I need. This Select Query works great and I believe it give me the correct data. Now I want to put that data into a Temp table so I can link in the other tables to get the other data that I need to get from these Case_Seq.
Select DISTINCT case_table.case_seq
FROM ((agent RIGHT JOIN (client LEFT JOIN client_agent_link ON client.client_seq = client_agent_link.client_seq) ON agent.agent_seq = client_agent_link.agent_seq) RIGHT JOIN case_table ON client.client_seq = case_table.client_seq) LEFT JOIN case_history ON case_table.case_seq = case_history.case_seq
WHERE (((case_history.case_type_seq)=2 Or (case_history.case_type_seq)=6 Or (case_history.case_type_seq)=23 Or (case_history.case_type_seq)=9 Or (case_history.case_type_seq)=13 Or (case_history.case_type_seq)=14) AND ((case_history.case_open_date)>='5/1/2003') AND ((client_agent_link.ca_link_to_date) Is Null) AND ((agent.agent_initials)<>'SCL' And (agent.agent_initials) Not Like '%0%'));
I need to put this data into a Temp table called CaseSeq with a Column named Case_Seq of type INT and then link that temp table to other data tables via the Case_Seq field in the CaseSeq Table.
Please help,
Thomas.
Select DISTINCT case_table.case_seq
FROM ((agent RIGHT JOIN (client LEFT JOIN client_agent_link ON client.client_seq = client_agent_link.client_seq) ON agent.agent_seq = client_agent_link.agent_seq) RIGHT JOIN case_table ON client.client_seq = case_table.client_seq) LEFT JOIN case_history ON case_table.case_seq = case_history.case_seq
WHERE (((case_history.case_type_seq)=2 Or (case_history.case_type_seq)=6 Or (case_history.case_type_seq)=23 Or (case_history.case_type_seq)=9 Or (case_history.case_type_seq)=13 Or (case_history.case_type_seq)=14) AND ((case_history.case_open_date)>='5/1/2003') AND ((client_agent_link.ca_link_to_date) Is Null) AND ((agent.agent_initials)<>'SCL' And (agent.agent_initials) Not Like '%0%'));
I need to put this data into a Temp table called CaseSeq with a Column named Case_Seq of type INT and then link that temp table to other data tables via the Case_Seq field in the CaseSeq Table.
Please help,
Thomas.