advanced query

  • Thread starter Thread starter Ghena
  • Start date Start date
G

Ghena

Hi everybody...

I'm trying to set a advanced query....

SELECT strutture.destinazione, strutture.localita, stru_serv.codoff,
stru_serv.id_strut, sistemazioni_base.tipo, sistemazioni_base.min_pax,
sistemazioni_base.max_pax, sistemazioni_base.id, partenze.data,
sistemazioni.dispo
FROM partenze INNER JOIN ((sistemazioni_base INNER JOIN (stru_serv
INNER JOIN strutture ON stru_serv.id_strut = strutture.id_strut) ON
sistemazioni_base.id_strut = strutture.id_strut) INNER JOIN
sistemazioni ON strutture.id_strut = sistemazioni.id_strut) ON
partenze.id_ogg = sistemazioni.id_ogg
GROUP BY strutture.destinazione, strutture.localita, stru_serv.codoff,
stru_serv.id_strut, sistemazioni_base.tipo, sistemazioni_base.min_pax,
sistemazioni_base.max_pax, sistemazioni_base.id, partenze.data,
sistemazioni.dispo
HAVING (((strutture.destinazione)="Francia") AND
((sistemazioni_base.max_pax)=3));


now I Would to add an expression to this query and get the value from a
query results.

the query is:

SELECT Sum(pren3.totpax) AS tot, pren3.id_sogg
FROM pren3
GROUP BY pren3.id_sogg;

but I get a sintax error
 
Ghena,

It's not apparent what you're trying to do here. If your first
Query, "SELECT strutture.destinazione, ...", is called [pren3], then
neither [totpax] nor [id_sogg] is a field in the Query, so there is no
value for the second Query to display.

Incidentally, in the first Query, since you never call an aggregate
function (such as Max() or Sum()), there's no need for the "GROUP BY"
clause in your SQL.

It also wasn't apparent which fields were intended to serve as
primary keys in their respective Tables. For example, is [id_strut] or
[id_ogg] the primary key of some Table(s)? If so, which one(s)?

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top