IonelBurtan
Programmer
There are two tables :
Table 1(Tab1)
Id int
Table 2(Tab2)
Id int
Type char(1)
Table 1 has a one-to-many relationship with table 2 like this: For each record from table 1 may corespond 1, 2 or 3 records in table 2.
Field Type may have 3 values 'S', 'D', 'I'.
I would like to select one record from table 2 like this:
if exists one record with Type='S' I select this one, if not I select the one with Type = 'D', if this does not exist I select the one with type = 'I' for a given Id from the first table in variable @Id.
So my value order for this field is 'S''D''I'.
How do I do that? I have solve the problem but in a complicated way. I want to do it in a simpler and less full of subqueries way.
Thank you all,
Urgent!!!
s-)
Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
Table 1(Tab1)
Id int
Table 2(Tab2)
Id int
Type char(1)
Table 1 has a one-to-many relationship with table 2 like this: For each record from table 1 may corespond 1, 2 or 3 records in table 2.
Field Type may have 3 values 'S', 'D', 'I'.
I would like to select one record from table 2 like this:
if exists one record with Type='S' I select this one, if not I select the one with Type = 'D', if this does not exist I select the one with type = 'I' for a given Id from the first table in variable @Id.
So my value order for this field is 'S''D''I'.
How do I do that? I have solve the problem but in a complicated way. I want to do it in a simpler and less full of subqueries way.
Thank you all,
Urgent!!!
s-)
Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...