Hi everybody!
I need to compose a SQL statement for the following task. I have three
tables
T1: refkey, value
T2: refkey, indexnumber, indexvalue
T3: refkey, functionnumber
There are several entries for refkey in each tables, it is not unique.
Refkey is the link for all three tables. I need to select all t1.value
for which the following conditions are true:
(t1.refkey=t2.r efkey=t3.refkey )
C1. If t2.indexnumber= 100 and t2.indexvalue=0 , and there is no
t2.indexnumber= 105 for this refkey, then select
C1. If t2.indexnumber= 100 and t2.indexvalue=0 , and there is
t2.indexnumber= 105 for this refkey and its t2.indexvalue=0 , then
select
C3. If t3.functionnumb er is not in (200,300) and C1 or C2 is true,
then select
I'm completely unable to write this sql statement. Any advise on how
to join these tables. BTW: We are talking about 12mio entries in T1
and the select needs to be cost sensitive.
Thanks alot for your help
Karsten
I need to compose a SQL statement for the following task. I have three
tables
T1: refkey, value
T2: refkey, indexnumber, indexvalue
T3: refkey, functionnumber
There are several entries for refkey in each tables, it is not unique.
Refkey is the link for all three tables. I need to select all t1.value
for which the following conditions are true:
(t1.refkey=t2.r efkey=t3.refkey )
C1. If t2.indexnumber= 100 and t2.indexvalue=0 , and there is no
t2.indexnumber= 105 for this refkey, then select
C1. If t2.indexnumber= 100 and t2.indexvalue=0 , and there is
t2.indexnumber= 105 for this refkey and its t2.indexvalue=0 , then
select
C3. If t3.functionnumb er is not in (200,300) and C1 or C2 is true,
then select
I'm completely unable to write this sql statement. Any advise on how
to join these tables. BTW: We are talking about 12mio entries in T1
and the select needs to be cost sensitive.
Thanks alot for your help
Karsten
Comment