Query with subquery

  • Thread starter Thread starter Mon
  • Start date Start date
M

Mon

I try to make a grouping query from the result of a union
query. Data comes from a vinculated table from postgres and
it works fine in php or pgadmin:

select feo.usu as usu, feo.tobra as tobra, feo.obra as
obra, count(feo.obra) as numjor from
(select usu, c_obr_t_1 as tobra, c_obr_1 as obra from
ing_prograobras2 where c_obr_1 <> '' and fecha between
#01/02/2004# and #01/03/2004#
union all select usu, c_obr_t_2 as tobra, c_obr_2 as obra
from ing_prograobras2 where c_obr_2 <> '' and fecha between
#01/02/2004# and #01/03/2004#
union all select usu, c_obr_t_3 as tobra, c_obr_3 as obra
from ing_prograobras2 where c_obr_3 <> '' and fecha between
#01/02/2004# and #01/03/2004#
union all select usu, c_obr_t_4 as tobra, c_obr_4 as obra
from ing_prograobras2 where c_obr_4 <> '' and fecha between
#01/02/2004# and #01/03/2004# order by usu)
as feo group by feo.usu, feo.obra, feo.tobra order by feo.usu

But that query doesn't works in access (sintax error). How
can I do something like that from VB for Access? The date
is dinamic.
 
Try saving your union query as a separate QueryDef
object. Then use the new QueryDef's name in your FROM
clause. That approach will work for sure.
 
It was what I was searching, thanks :)
-----Original Message-----
Try saving your union query as a separate QueryDef
object. Then use the new QueryDef's name in your FROM
clause. That approach will work for sure.
 
Back
Top