2016-11-11 46 views
0
with temp as(
select a.fk_audit_inserimento 
from mtd.t_mtd_all_dt_elab_etl a,mtd.t_mtd_all_dt_anag_etl b 
where a.fk_etl_caricamento=b.pk_etl_caricamento 
and b.sds_livello='DMT' and b.sds_nome_etl='JOB_DM_MOBILE_CODE' 
order by 1 desc 
limit 2 
) 

select 
case 
when 
(select count(*) from temp)=1 
then 
(select 19000101000000, 
union 
select fk_audit_inserimento from temp) 
when 
(select count(*) from temp)=2 
then (select fk_audit_inserimento from temp) 
end 

我想這 If count (*) of TEMP =1那麼我想兩個記錄19000101000000表達一個子查詢返回多行和select fk_audit_inserimento from temp; If count(*) of TEMP =2那麼我想select fk_audit_inserimento from temp.Postgres的情況下錯誤:通過使用

但我

ERROR: multiple rows.

我該如何解決?

THANKS

回答

1

試試沿着這些線路:

SELECT 19000101000000 
WHERE (SELECT count(*) FROM temp)=1 
UNION 
SELECT fk_audit_inserimento FROM temp ; 
相關問題