G
Ghena
Hi, I know this query is very difficult if you have not the
relationship beetween all the table.
But I need to filter this table to obtain only one record choosen as
the minimum of "DIFF" field
live example:
id tipo id_sogg id_ogg prezzo_cat dispo set_richiesta max_pax min_pax diff totale_pax DISPREALE STATUS
29 tripla 3268 1040 € 218,00 0 Vero 3 2 1 0 0 rq
46 Quadrupla 3348 1040 € 444,00 35 Vero 4 2 2 27 8 ok
I need to display the min(diff) of both
id tipo id_sogg id_ogg prezzo_cat dispo set_richiesta max_pax min_pax diff totale_pax DISPREALE STATUS
29 tripla 3268 1040 € 218,00 0 Vero 3 2 1 0 0 rq
this results is the minimum DIFF (1)
how could I display filter by min(diff) and display all the columns?
This is the actual query.
SELECT sistemazioni_base.id, sistemazioni_base.tipo,
sistemazioni.id_sogg, sistemazioni.id_ogg, sistemazioni.prezzo_cat,
sistemazioni.dispo, sistemazioni_base.min_pax,
sistemazioni_base.max_pax, [max_pax]-2 AS diff, offerte.set_richiesta,
IIf(IsNull(Sommapax),0,Sommapax) AS totale_pax, dispo-totale_pax AS
DISPREALE, IIf(DISPREALE<=0,IIf(SET_RICHIESTA=True,'rq','ko'),'ok') AS
STATUS
FROM ((sistemazioni_base INNER JOIN sistemazioni ON
sistemazioni_base.id = sistemazioni.id_tipo) INNER JOIN offerte ON
sistemazioni_base.codoff = offerte.codoff) INNER JOIN somma_totpax ON
sistemazioni.id_sogg = somma_totpax.id_sogg
WHERE (((sistemazioni.id_ogg)=1040) AND
((sistemazioni_base.min_pax)<=2) AND ((sistemazioni_base.max_pax)>=2)
AND ((sistemazioni_base.id_strut)=11));
relationship beetween all the table.
But I need to filter this table to obtain only one record choosen as
the minimum of "DIFF" field
live example:
id tipo id_sogg id_ogg prezzo_cat dispo set_richiesta max_pax min_pax diff totale_pax DISPREALE STATUS
29 tripla 3268 1040 € 218,00 0 Vero 3 2 1 0 0 rq
46 Quadrupla 3348 1040 € 444,00 35 Vero 4 2 2 27 8 ok
I need to display the min(diff) of both
id tipo id_sogg id_ogg prezzo_cat dispo set_richiesta max_pax min_pax diff totale_pax DISPREALE STATUS
29 tripla 3268 1040 € 218,00 0 Vero 3 2 1 0 0 rq
this results is the minimum DIFF (1)
how could I display filter by min(diff) and display all the columns?
This is the actual query.
SELECT sistemazioni_base.id, sistemazioni_base.tipo,
sistemazioni.id_sogg, sistemazioni.id_ogg, sistemazioni.prezzo_cat,
sistemazioni.dispo, sistemazioni_base.min_pax,
sistemazioni_base.max_pax, [max_pax]-2 AS diff, offerte.set_richiesta,
IIf(IsNull(Sommapax),0,Sommapax) AS totale_pax, dispo-totale_pax AS
DISPREALE, IIf(DISPREALE<=0,IIf(SET_RICHIESTA=True,'rq','ko'),'ok') AS
STATUS
FROM ((sistemazioni_base INNER JOIN sistemazioni ON
sistemazioni_base.id = sistemazioni.id_tipo) INNER JOIN offerte ON
sistemazioni_base.codoff = offerte.codoff) INNER JOIN somma_totpax ON
sistemazioni.id_sogg = somma_totpax.id_sogg
WHERE (((sistemazioni.id_ogg)=1040) AND
((sistemazioni_base.min_pax)<=2) AND ((sistemazioni_base.max_pax)>=2)
AND ((sistemazioni_base.id_strut)=11));