SQL query according to Column make a new one

0

I have a column that is numeric. There are positive and negative values in this column. I need to make a query that when it is positive, I query Tabela A , when it is negative I refer to Tabela B . I have no idea how to do this, can you do that?

    
asked by anonymous 11.12.2015 / 14:40

1 answer

0

One possible solution is:

Create a view that links to both

tables

create or replace view v_view as
select cod,nome
from tabela1
union 
select cod,nome
from tabela2

Join in the view

select *
from tabela3,v_view
where v_view.cod = tabela3.cod 
    
11.12.2015 / 15:20