我在SQL方面很薄弱。我有一個有3列和基本選擇語句的小表。選擇另一個語句如果沒有行返回Oracle
select intl, loc FROM test_table where p.country = 'UAE'
但在某些情況下沒有行返回,在這種情況下,我想從同一個表中選擇另一個語句。
我發現下面的查詢,但我不能得到它的工作。
select intl, loc FROM test_table
where p.country = 'UAE'
union all
select 'intl','Loc' from dual
where not exists (select intl, loc FROM test_table where p.country = 'Other')
我知道它很簡單,但我堅持了幾個小時。 感謝名單
謝謝。這是我需要的 – ShB