I need to join two tables using a substr() of a column. Using the example below, I want to join TableA and TableB by substr(TableA,1,4)=TableB unless there is a substr(TableA,1,6)=TableB. In that case, I want to use substr(TableA,1,6). I can do that in a SQL statement using a correlated sub-query something like:
select... where substr(TableA,1,6)=TableB or (substr(TableA,1,4)=TableB and not exists (select 1 from TableB(2) where substr(TableA,1,6)=TableB)
However, Impromptu has a mind of its own, and unless I code the SQL myself it doesn't do the join correctly.
TableA TableB
12342913 1234
12340164 123401
12350165 1235
I guess I could create a view, but I'm wondering whether there is another solution. Thanks.
select... where substr(TableA,1,6)=TableB or (substr(TableA,1,4)=TableB and not exists (select 1 from TableB(2) where substr(TableA,1,6)=TableB)
However, Impromptu has a mind of its own, and unless I code the SQL myself it doesn't do the join correctly.
TableA TableB
12342913 1234
12340164 123401
12350165 1235
I guess I could create a view, but I'm wondering whether there is another solution. Thanks.