SQL -显示第一个表中的所有值

  • 本文关键字:显示 第一个 SQL sql
  • 更新时间 :
  • 英文 :


我想显示列'nation '的所有值。

查询表"nation"中的Nationen_bez '
SELECT DISTINCT nation.nationen_bez,   
NVL(SUM (debitor.flimit_deb) OVER (PARTITION BY nation.nationen_bez ORDER BY nation.nationen_bez),0) AS korisceno,   
NVL(nation_ext.country_limit,0) - NVL(SUM (debitor.flimit_deb) OVER (PARTITION BY nation.nationen_bez ORDER BY nation.nationen_bez),0) AS se_na_voljo,   
NVL(nation_ext.country_limit,0) AS odobren_limit  
FROM debitor,   
nation,   
nation_ext,   
firmenstamm,   
debitorenstamm  
WHERE ( nation.nationen_kode = debitorenstamm.nationen_kode (+)) and  
( nation.nationen_id = nation_ext.nationen_id (+)) and  
( debitor.debitoren_id = debitorenstamm.debitoren_id ) and  
( debitorenstamm.waehrungs_id = firmenstamm.waehrungs_id ) and  
( ( debitor.risiko = 1 ) AND  
( debitor.factoringart = 'EF' ))

使用这个查询,我只得到那些'nation '。Nationen_bez ',其中存在债务人与债务人。Risiko = 1和债务人。factoringart = 'EF'。此条件需要在"NVL(SUM(债务方.flimit_deb) OVER (PARTITION BY nation)"中使用。nationen_bez ORDER BY nation.nationen_bez),0) AS korisceno',因为我只想对那些有debitor的债务人求和'flimit_deb'。Risiko = 1和债务人。factoringart = 'EF' -我如何改变这个状态?

tnx in advance

我使用了左连接,以nation开头

SELECT DISTINCT nation.nationen_bez, 
SUM (debitor.flimit_deb) OVER (PARTITION BY nation.nationen_bez ORDER BY nation.nationen_bez) AS korisceno,   
nation_ext.country_limit - SUM (debitor.flimit_deb) OVER (PARTITION BY nation.nationen_bez ORDER BY nation.nationen_bez) AS se_na_voljo,   
nation_ext.country_limit AS odobren_limit  
FROM nation
left join debitorenstamm on nation.nationen_kode = debitorenstamm.nationen_kode
left join debitor on debitorenstamm.debitoren_id =  debitor.debitoren_id and debitor.risiko = 1 AND  debitor.factoringart = 'EF' 
left join nation_ext on nation.nationen_id = nation_ext.nationen_id   
left join firmenstamm on  debitorenstamm.waehrungs_id = firmenstamm.waehrungs_id

相关内容

最新更新