如何从Firebird 1.5

时间:2015-12-30 07:37:12

标签: sql select firebird

我得到了Firebird 1.5的这个查询:

select * from (
select
ddddd.name,
gggg.land,
dd.maskenkey,
ddd.name,
Sum(b.epreis*a.menge),  
Sum((kx.epreis / lx.kurs) * a.menge),
sum(case when b.bverpa_id='1' then (a.menge*e.p_volume)/e.pcs_box else a.menge*e.P_PCS_20ST end) as jumlah 
from brrcp a  
left outer join baufpo b on a.baufpo_id_aufnrpos = b.id 
left outer join brrc c on a.brrc_id_rgnr = c.id  
left outer join bauf d on b.bauf_id_linkkey = d.id 
left outer join bkunde dd on d.bkunde_id_kunr = dd.id  
left outer join badr ddd on dd.badr_id_adrnr = ddd.id 
left outer join bvert dddd on d.bvert_id = dddd.id  
left outer join badr ddddd on dddd.badr_id = ddddd.id 
left outer join bbesp kx on b.id = kx.baufpo_id_aufpos  
left outer join bbes aa on kx.bbes_id_linkkey = aa.id 
left outer join bsal yy on kx.bsal_id = yy.id  
left outer join bwaer lx on kx.bwaer_id_waehrungk = lx.id  
left outer join bplz zz on ddd.bplz_id_landplz = zz.id 
left outer join bland gggg on zz.bland_id_landkennz = gggg.id 
left outer join bsa e on a.bsa_id_artnr = e.id  
where c.eta_shipment between '01/01/2015' and '6/30/2015'
and dd.maskenkey starting 'AS-' and d.cancel = 'N' and d.confirm = 'N' and aa.status_po <> 'C'  
and d.auftrag = 'J' and a.rg_buchungsart Is Null
group by ddddd.name,gggg.land,dd.maskenkey,ddd.name) abc

如何修复其结构,因为当我想执行此查询时,我会收到错误?谢谢 !!

**Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 2, char 1.
select.**

1 个答案:

答案 0 :(得分:3)

您正在FROM子句中使用select,这称为derived table,并且您无法在Firebird 1.5或更早版本中使用派生表。

此功能was introduced 9 years ago in Firebird 2.0。因此,如果您想在查询中使用它,则应升级(如果您这样做,请升级到Firebird 2.5.5)。在升级之前,请务必仔细阅读Firebird 2.0,2.1和2.5 release notes以及Firebird 2 Migration & installation Notes以了解您需要考虑的任何兼容性更改。

您问题中的查询本身并不需要派生表,只需从查询中删除外部SELECT * FROM (....) abc,它就会 - 在发布时 - 没有附加值。