我有一個類似于下面的表格,想知道是否在幾天內有實際和預測來洗掉預測行,只保留實際?

uj5u.com熱心網友回復:
一種方法是與存在檢查聯合
select date,type,value from t where type ='actual'
union all
select date,type,value from t where type ='forecast'
and not exists (select 1 from t t1 where t1.date = t.date and t1.type = 'actual') ;
而且由于不能保證和實際會有預測或預測會有實際,這比模擬完全連接要簡單一些,盡管不一定更快。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/404819.html
標籤:
