i have a number of ombrella free?

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

i have a number of ombrella free?

Post by sal21 »

i need to check if in FILA=1, have a free number of ombrella beach by GIORNO=01/08/2021, in my case have a number 20 ombrella...

FILA is the number of row.
NUMERO is the number of ombrella per row (FILA)

for each FILA I CAN HAVE A FIXED NUMBER OF OMMBRELLA=50

I i need a SQL, to select all number of ombrella free, by FILA...

in my case FILA 1 have only a free NUMERO=20
You do not have the required permissions to view the files attached to this post.

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

Re: i have a number of ombrella free?

Post by HansV »

See the attached database. I created two auxiliary tables and a query.
The query returning the free umbrellas is LIBERO.

OMBRELLONI.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
04 Sep 2021, 10:14
See the attached database. I created two auxiliary tables and a query.
The query returning the free umbrellas is LIBERO.


OMBRELLONI.zip
:clapping: :clapping: :clapping: :clapping:

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
04 Sep 2021, 10:14
See the attached database. I created two auxiliary tables and a query.
The query returning the free umbrellas is LIBERO.


OMBRELLONI.zip
OPS...
i have just modified my post when you write a solution ...

i need to add also a GIORNO in the where clausole, sorry..

for example ... WHERE OMBRELLONI.GIORNO=15/08/2021 ...

TKS.

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

Re: i have a number of ombrella free?

Post by HansV »

See below.

OMBRELLONI.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
04 Sep 2021, 12:50
See below.


OMBRELLONI.zip
TKS, work.

But in this case, with the new sql, i can use, also a between statement from two days, or not?

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

Re: i have a number of ombrella free?

Post by HansV »

Yes, replace

WHERE OMBRELLONI.GIORNO=#8/01/2021#

with for example

WHERE OMBRELLONI.GIORNO BETWEEN #8/01/2021# AND #8/12/2021#

Remember that you must specify dates in US format m/d/yyyy in SQL.
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
04 Sep 2021, 14:44
Yes, replace

WHERE OMBRELLONI.GIORNO=#8/01/2021#

with for example

WHERE OMBRELLONI.GIORNO BETWEEN #8/01/2021# AND #8/12/2021#

Remember that you must specify dates in US format m/d/yyyy in SQL.
TESTED and it work!

sorry...
if i can extract only a distinct value of FILA, based a free NUMBER?

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

Re: i have a number of ombrella free?

Post by HansV »

What do you mean? I'm afraid I don't understand.
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
04 Sep 2021, 15:32
What do you mean? I'm afraid I don't understand.
TKS.
RESOLVED MY SELF.

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
04 Sep 2021, 14:44
Yes, replace

WHERE OMBRELLONI.GIORNO=#8/01/2021#

with for example

WHERE OMBRELLONI.GIORNO BETWEEN #8/01/2021# AND #8/12/2021#

Remember that you must specify dates in US format m/d/yyyy in SQL.

SELECT DISTINCT COMBI.NUMERO
FROM COMBI LEFT JOIN (SELECT * FROM OMBRELLONI WHERE OMBRELLONI.FILA=2 AND OMBRELLONI.GIORNO=#08/01/2021#) AS Q ON (COMBI.FILA = Q.FILA) AND (COMBI.NUMERO = Q.NUMERO)
WHERE Q.FILA IS NULL
ORDER BY COMBI.NUMERO

why have a complete list 50!

see image with filter on FILA and GIORNO
You do not have the required permissions to view the files attached to this post.

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

Re: i have a number of ombrella free?

Post by HansV »

What is the problem? I see only 5 records in the screenshot.
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
05 Sep 2021, 07:52
What is the problem? I see only 5 records in the screenshot.
yes...
but 50-5(not freeable)=45... the query return a complete list of 50 free

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

Re: i have a number of ombrella free?

Post by HansV »

Sorry, I don't understand. Could you attach the database with the query?
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
05 Sep 2021, 09:16
Sorry, I don't understand. Could you attach the database with the query?
SELECT DISTINCT COMBI.NUMERO
FROM COMBI LEFT JOIN (SELECT * FROM OMBRELLONI WHERE OMBRELLONI.FILA= 2 AND OMBRELLONI.GIORNO=#8/01/2021#) AS Q ON (COMBI.FILA = Q.FILA) AND (COMBI.NUMERO = Q.NUMERO)
WHERE Q.FILA Is Null
ORDER BY COMBI.NUMERO

I need to return in a distinct set of a free NUMERO of OMBRELLONI based FILA=2 and GIORNO=01/08/2021.

in this case are not free only 5 NUMBER (you see in screenshot)
You do not have the required permissions to view the files attached to this post.

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

Re: i have a number of ombrella free?

Post by HansV »

SELECT DISTINCT COMBI.NUMERO
FROM COMBI LEFT JOIN (SELECT * FROM OMBRELLONI WHERE OMBRELLONI.FILA= 2 AND OMBRELLONI.GIORNO=#8/01/2021#) AS Q ON (COMBI.NUMERO = Q.NUMERO) AND (COMBI.FILA = Q.FILA)
WHERE (((COMBI.FILA)=2) AND ((Q.FILA) Is Null))
ORDER BY COMBI.NUMERO;
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
05 Sep 2021, 10:04
SELECT DISTINCT COMBI.NUMERO
FROM COMBI LEFT JOIN (SELECT * FROM OMBRELLONI WHERE OMBRELLONI.FILA= 2 AND OMBRELLONI.GIORNO=#8/01/2021#) AS Q ON (COMBI.NUMERO = Q.NUMERO) AND (COMBI.FILA = Q.FILA)
WHERE (((COMBI.FILA)=2) AND ((Q.FILA) Is Null))
ORDER BY COMBI.NUMERO;
But this query return a list of 50 NUMERO free!(immagine.jpg)

i need a list of 45 NUMERO free!

see the immagine1.jpg are the NUMERO just not free

i need
1
2
3
4
5
6
7
8
9
10
11
13
14
15
16
18
20
....
38
40
41
43
...
50

in my report(immagine2.jpg) the blank cell are the free NUMERO free
You do not have the required permissions to view the files attached to this post.

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

Re: i have a number of ombrella free?

Post by HansV »

S0735.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by HansV »

Here is the database with the query.

OMBRELLONI.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

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

Re: i have a number of ombrella free?

Post by sal21 »

HansV wrote:
05 Sep 2021, 11:16
Here is the database with the query.


OMBRELLONI.zip
I'm sorry but I did it all without attention

i used your query in a very very old database...

Your sql work like a charm!

Sorry