Group query

M

Matti Koski

Group query



I have groups in column1 and values in column2. I would like to pick up all
the groups that have values in column2. If the value is zero in column2 in
some group, the whole group should not exist in the query. (See below groups
A and C should not exist).



A 2

B 3

A 1

C 2

D 4

A

D 5

C

F 3



Matti
 
G

Guest

Hi Matti

Quick one this ;-)

Place this is the criteria row of column 2

Not Is Null

Oh by the way - you said that some of the records in column 2 are Zero (0)
but in the example you posted you showed Null - there is a big difference.
Just a point.

Hope this helps
 
J

John W. Vinson

Group query



I have groups in column1 and values in column2. I would like to pick up all
the groups that have values in column2. If the value is zero in column2 in
some group, the whole group should not exist in the query. (See below groups
A and C should not exist).

Not zero? or not null? Zero is a number, a legitimate value; NULL is
the ABSENCE of a number.

That said: in order to exclude all A and C records from the query
because there are NULLs (or zeros) in at least one A or C record, you
need a Subquery:

SELECT Column1, Column2
FROM yourtable
WHERE NOT EXISTS
(SELECT Column1 FROM yourtable AS X
WHERE X.Column1 = yourtable.Column1
AND NZ(X.Column2) = 0);


John W. Vinson [MVP]
 
M

Matti Koski

Sorry

I ment naturally null values.

Matti
John W. Vinson said:
Not zero? or not null? Zero is a number, a legitimate value; NULL is
the ABSENCE of a number.

That said: in order to exclude all A and C records from the query
because there are NULLs (or zeros) in at least one A or C record, you
need a Subquery:

SELECT Column1, Column2
FROM yourtable
WHERE NOT EXISTS
(SELECT Column1 FROM yourtable AS X
WHERE X.Column1 = yourtable.Column1
AND NZ(X.Column2) = 0);


John W. Vinson [MVP]
 

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

Sum of counted values in a query 2
Check box count from subdatasheet 2
search function 2
VBAscript for data matching excels 0
Forma 6
Cumulative counts in a query-column 1
Running Sum not working 1
ODBC and Excel 1

Top