SELECT a.yb,
a.deung_day, a.command,
case coalesce(a.ok_yn,'')when'Y'then'적립'else'미적립'end as ok_yn,
case coalesce(a.hg_yn,'')when'Y'then'발행'else'미발행'end as hg_yn,
case coalesce(lmulcode,'')when '' then '' else '증정'end as book
FROM t_sugangsave_gita a left outer join
dblink('hostaddr=221.151.xxx.72 port=5432 dbname=sc_book user=postgres password=0000',
'SELECT distinct t_sale.yb, max(t_sale.mid)as mid, max(t_sale.mulcode)as mulcode
from t_sale left outer join t_mulpum m on m.mid=t_sale.mid and m.mulcode=t_sale.mulcode group by t_sale.yb
') as (lyb varchar(10),lmid varchar(20),lmulcode varchar(15)) on a.mid=lmid and a.yb=lyb
Where a.mid='scall' and a.stu_c=10051556
문제는 다른 DB에 있는 case coalesce(lmulcode,'')when '' then '' else '증정'end as book 하나를 구하기 위해서 dblink를 걸어
속도가 떨어지다는 겁니다.
dblink가 잘못되었거나 다른 좋은 방법이 없나요?
|