问题描述
我正在尝试从另一个数据库“ Finantial”中获取数据,但返回的结果与我在另一个数据库中使用相同代码减去dblinks得到的结果不同
这是我遇到问题的代码:
select trans.accountid,sum(trans.amount)as montantpaye,loan.amount-sum(trans.amount) as montantrestant,loan.duration-count(trans.transid) as moisrestant
from (SELECT * FROM dblink('user=postgres password=password dbname=finantial','select amount,accountid,duration from loan')
AS loan(amount int,accountid int,duration int)) as loan,(SELECT * FROM dblink('user=postgres password=password dbname=finantial','select accountid from account')
AS account(accountid int)) as account,ksymbol,transid from trans')
AS trans(accountid int,amount int,ksymbol varchar,transid int)) as trans
where trans.ksymbol='UVER' and
account.accountid=loan.accountid and
trans.accountid=account.accountid
group by (trans.accountid,loan.amount,loan.duration)
这就是我得到的
而当我使用以下代码在“ finantial”数据库中查询此数据时:
select trans.accountid,sum(trans.amount)as montant_paye,loan.amount-sum(trans.amount) as montant_restant,loan.duration-count(trans.transid) as moisrestant
from loan,account,trans
where account.accountid=loan.accountid and ksymbol='UVER' and trans.accountid=account.accountid
group by (trans.accountid,loan.duration)
我得到这个结果:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)