VIEW also a free room SINGOLA

User avatar
sal21
PlatinumLounger
Posts: 4470
Joined: 26 Apr 2010, 17:36

VIEW also a free room SINGOLA

Post by sal21 »

Actually the query show also a reserved room, now i need to show also a free room of SINGOLA

in this case idtip in STANZE >SINGOLA:
12
13
14
16
18
19
20
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 79287
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VIEW also a free room SINGOLA

Post by HansV »

Try

SELECT PRENOTAZIONI.IDTIP, PRENOTAZIONI.TIPO, [PRENOTAZIONI].[IDCLI] & '-' & [COGNOME] & ' ' & [NOME] & '-(' & [DTNASC] & ')' AS CLIENTE, PRENOTAZIONI.DAL, PRENOTAZIONI.AL, PRENOTAZIONI.NRGG
FROM STANZE LEFT JOIN (PRENOTAZIONI LEFT JOIN ANAGRAFICA ON PRENOTAZIONI.IDCLI = ANAGRAFICA.IDCLI) ON STANZE.IDTIP = PRENOTAZIONI.IDTIP
WHERE (((PRENOTAZIONI.TIPO)='SINGOLA') And ((PRENOTAZIONI.AAAA)='2024') And ((PRENOTAZIONI.MM)='8') And ((PRENOTAZIONI.STRUTTURA)="MARE") And ((STANZE.STRUTTURA)="MARE"))
UNION SELECT STANZE.IDTIP, STANZE.TIPO, Null AS CLIENTE, Null AS DAL, Null AS AL, Null AS NRGG
FROM STANZE
WHERE (((STANZE.IDTIP) Not In (SELECT IDTIP FROM PRENOTAZIONI WHERE TIPO="SINGOLA" AND STRUTTURA="MARE" AND AAAA="2024" AND MM="8")) AND ((STANZE.TIPO)="SINGOLA") AND ((STANZE.STRUTTURA)="MARE"));
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4470
Joined: 26 Apr 2010, 17:36

Re: VIEW also a free room SINGOLA

Post by sal21 »

Super great!
But really not for my experince in sql.
Tks Hans.

User avatar
sal21
PlatinumLounger
Posts: 4470
Joined: 26 Apr 2010, 17:36

Re: VIEW also a free room SINGOLA

Post by sal21 »

HansV wrote:
09 Aug 2024, 09:09
Try

SELECT PRENOTAZIONI.IDTIP, PRENOTAZIONI.TIPO, [PRENOTAZIONI].[IDCLI] & '-' & [COGNOME] & ' ' & [NOME] & '-(' & [DTNASC] & ')' AS CLIENTE, PRENOTAZIONI.DAL, PRENOTAZIONI.AL, PRENOTAZIONI.NRGG
FROM STANZE LEFT JOIN (PRENOTAZIONI LEFT JOIN ANAGRAFICA ON PRENOTAZIONI.IDCLI = ANAGRAFICA.IDCLI) ON STANZE.IDTIP = PRENOTAZIONI.IDTIP
WHERE (((PRENOTAZIONI.TIPO)='SINGOLA') And ((PRENOTAZIONI.AAAA)='2024') And ((PRENOTAZIONI.MM)='8') And ((PRENOTAZIONI.STRUTTURA)="MARE") And ((STANZE.STRUTTURA)="MARE"))
UNION SELECT STANZE.IDTIP, STANZE.TIPO, Null AS CLIENTE, Null AS DAL, Null AS AL, Null AS NRGG
FROM STANZE
WHERE (((STANZE.IDTIP) Not In (SELECT IDTIP FROM PRENOTAZIONI WHERE TIPO="SINGOLA" AND STRUTTURA="MARE" AND AAAA="2024" AND MM="8")) AND ((STANZE.TIPO)="SINGOLA") AND ((STANZE.STRUTTURA)="MARE"));
OPS...

same query, but without to select a where calusole SINGOLA.... In effect i need for all type of room, reserved and not reserved

Sorry

User avatar
HansV
Administrator
Posts: 79287
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VIEW also a free room SINGOLA

Post by HansV »

Remove the condition ((PRENOTAZIONI.TIPO)='SINGOLA') and also TIPO="SINGOLA"
Best wishes,
Hans