Author: Rohit Umarjikar
Posted: Wed Dec 14, 2016 11:15 pm (GMT 5.5)
RahulG31, I think, you are missing the relation between two tables.
Arun, I would like that approach but what if table2 doesn't have a matching row? in your case it will still be marked as 'X' but OP wants to mark X only for the entries other than (ABCD).
Nitin,
Welcome!
Before you expect a solution to the problem, please state the problem correctly along with the table structure, sample data and the desired output because right now it is a guess work.
However, based on what is stated, try this.
_________________
Regards,
Rohit Umarjikar
"Knowledge is knowing that a tomato is a fruit, but Wisdom is knowing not to put it in a fruit salad."![icon_razz.gif]()
Posted: Wed Dec 14, 2016 11:15 pm (GMT 5.5)
RahulG31, I think, you are missing the relation between two tables.
Arun, I would like that approach but what if table2 doesn't have a matching row? in your case it will still be marked as 'X' but OP wants to mark X only for the entries other than (ABCD).
Nitin,
Welcome!
Before you expect a solution to the problem, please state the problem correctly along with the table structure, sample data and the desired output because right now it is a guess work.
However, based on what is stated, try this.
Code: |
select T3.ID1, T3.code2 from (SELECT T1.ID as ID1, T2.code1 as code2, case when T2.code1 = 'X' then 1 when T2.code1 = 'B' then 2 when T2.code1 = 'A' then 3 when T2.code1 = 'C' then 4 when T2.code1 = 'D' then 5 end FROM TABLE1 T1, (SELECT ID,case when CODE NOT IN ('A','B','C','D') then 'X' else CODE end as code1 FROM TABLE2 ) T2 where T1.ID = T2.ID order by 3) as T3 |
_________________
Regards,
Rohit Umarjikar
"Knowledge is knowing that a tomato is a fruit, but Wisdom is knowing not to put it in a fruit salad."
