Re: Group by, Then Count, Then write out results



Mel via AccessMonster.com wrote:
I'm not sure how to do this. I need to create an exception report.
So, I need to create a query for the report.

The query must
1. search for all accounts that have the "Yes" flag
2. then it must group them by account #
3. then it must check for status within that account # group
3a. if the flag is "Yes" and any of the statuses = open, then this
is Not an exception (i can move to next group of account #'s

But,
3b. if the flag is "Yes" and all fo the statuses = closed for that
account# group, then this is an exception
3c. write this record out to a table or query (flag, account#, status,
custName)
(Yes, acct#1110, Closed, ABC Company)

3d. then move to the next account # group and do 3b & 3c again, until
end of file

4. The info in #3c above is used for the exception report.

I'm not sure if 3c above should be a query or write it to a table
that will be deleted after the report is ran.

Create a new query in design view without selecting any tables, switch
it to SQL View and paste the following in. Correct the table name and
switch back to design view or run it.

Select flag,account#, "Closed" as [AcctStatus], custName
from accounts
where flag="Yes"
group by flag, account#, custName
having min(status)="closed" and max(status) = "closed"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Re: Need help creating a report in access
    ... to generate a report for work and require the following information to ... account#, name, address, etc. ... invalid account number ... Create a query using the wizard. ...
    (microsoft.public.access.gettingstarted)
  • RE: Query Criteria based on another table
    ... This query will select a range of random numbers. ... I would generate a report in access using the wizard that uses the above ... I would only show and count successful hits against my base ... tables (account numbers) and when it hit 200 successful hits I would stop ...
    (microsoft.public.access.queries)
  • Re: drop down and date range for report criteria
    ... Can you confirm that the AccountName you are selecting works in the query ... I added a Command Button pointing to the report I want. ... I added the criteria to the query Forms! ... When I select the Account name I want a report on, ...
    (microsoft.public.access.reports)
  • RE: Transpose data in a report-Field values broken down to separat
    ... I then created the subreport using the Gifts table, ... There was an account name in the Prospects table that has no "gift" ... properties, but since I didn't use a query, not sure how to go about that. ...
    (microsoft.public.access.reports)
  • Re: repeating parameter query
    ... "Duane Hookom" wrote: ... or report's record source query. ... the form is used to display the account information. ... which opened a report that could be printed. ...
    (microsoft.public.access.queries)