pokitlok
3rd January 2003, 05:39
I got a syntax error: "group" not expected as complie program session.
My purpose is to join purchase receipt transaction with the latest purchase orders' item prices and suppliers.
I have several kinds of "group" query but still got the same error.
Please help. Does "group" not work in subquery? (But, I found an example in some BaaN materials)
Baan code as below:
select tdinv700.*, tiitm001.*, tccom020.*, tdpur040.*, tdpur041.*
from tdinv700, tiitm001, tdpur041, tdpur040, tccom020
where tdinv700.trdt between :trdt.f and :trdt.t
and tdinv700.cwar between :cwar.f and :cwar.t
and tdinv700.kost = :kost
and tdinv700.item between :item.f and :item.t
and tdinv700.item refers to tiitm001
and tdpur041 refers to tdpur040
and tdpur041.item = tdinv700.item
and tdpur041.suno between :suno.f and :suno.t
and tdpur040.suno refers to tccom020
and tdpur040.odat in
(select m0.odat
from tdpur040 m0, tdpur041 m1
where m1 refers to m0
and m1.item = tdpur041.item
group by m1.item having max(m0.odat))
selectdo
rprt_send()
endselect
My purpose is to join purchase receipt transaction with the latest purchase orders' item prices and suppliers.
I have several kinds of "group" query but still got the same error.
Please help. Does "group" not work in subquery? (But, I found an example in some BaaN materials)
Baan code as below:
select tdinv700.*, tiitm001.*, tccom020.*, tdpur040.*, tdpur041.*
from tdinv700, tiitm001, tdpur041, tdpur040, tccom020
where tdinv700.trdt between :trdt.f and :trdt.t
and tdinv700.cwar between :cwar.f and :cwar.t
and tdinv700.kost = :kost
and tdinv700.item between :item.f and :item.t
and tdinv700.item refers to tiitm001
and tdpur041 refers to tdpur040
and tdpur041.item = tdinv700.item
and tdpur041.suno between :suno.f and :suno.t
and tdpur040.suno refers to tccom020
and tdpur040.odat in
(select m0.odat
from tdpur040 m0, tdpur041 m1
where m1 refers to m0
and m1.item = tdpur041.item
group by m1.item having max(m0.odat))
selectdo
rprt_send()
endselect