View Full Version : count records/show less than


Randomblink
10-01-2001, 06:49 AM
Ok, I have a database that shows all the items that need to be done per page.
There are some items that span more than one page and some pages that contain multiple items...
What we are trying to do is, Count up all the items per page...
Show all of them that have less than 3 items...
I have tried to create a calculated expression that counts up the field 'PAGE'...
I have tried to COUNT inside the field 'PAGE'...
as well as numerous other directions...
What is missing here...

Im not that strong in Queries, but isn't what Im trying to do is create an unbound field and run an expression in it? Then critera it?

I want to count up the 'PAGES' and then only show those that have a count of 3 and under...

ARGH!

Pat Hartman
10-01-2001, 07:41 PM
The simplest way is with two queries.

query1 (counts the number of items per page):

Select PageNum, Count(*) As PageCount
From YourTable
Where PageCount < 3
Group By PageNum;

query2 (return items for the pages selected by query1):

Select q1.PageNum, T.ItemNum, T.ItemName
From query1 As q1 Inner Join YourTable As T On q1.PageNum = T.PageNum;

Randomblink
10-02-2001, 07:16 AM
Ok, two queries...
The coding you gave me is that in SQL?
Where would I put it?
SQL view...?

Hmmm...

I really appreciate the help, I just am not sure how to implement this code you gave me...

Sorry I am so slow, but if you could clarify I would truly appreciate it...thanks man...

Pat Hartman
10-02-2001, 01:57 PM
What I posted was SQL. You would need to change the column and table names to whatever you used in your table. I would also suggest more meaningful names than query1 and query2.

Once you have retyped the SQL, you can open the querybuilder to a new query, change the view to SQL view and paste the code. You can then switch back to QBE view if you prefer.