A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Aggregate count function



 
 
Thread Tools Display Modes
  #1  
Old January 21st, 2005, 08:13 PM
Chris Motherwell via AccessMonster.com
external usenet poster
 
Posts: n/a
Default Aggregate count function

I've created a query that counts the number of records based on a criteria of Yes or No (for a Yes/No data type). Is there any way to have the results display a zero (or something) when there are no Yeses or Nos?

CM

--
Message posted via http://www.accessmonster.com
  #2  
Old January 21st, 2005, 10:35 PM
John Spencer (MVP)
external usenet poster
 
Posts: n/a
Default

I guess I am missing something here. How can you have zero yes and zero no in a
recordset? A yes/no field has to have one value or the other.

Are you applying some criteria and therefore returning zero records in the recordset?

"Chris Motherwell via AccessMonster.com" wrote:

I've created a query that counts the number of records based on a criteria of Yes or No (for a Yes/No data type). Is there any way to have the results display a zero (or something) when there are no Yeses or Nos?

CM

--
Message posted via http://www.accessmonster.com

  #3  
Old January 21st, 2005, 11:28 PM
Chris Motherwell via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

Thanks for the reply John.
Let's say the criteria is Yes for a Yes/No field. If there are no Yeses in the the data, is it possible to display a zero to show this result?

CM

--
Message posted via http://www.accessmonster.com
  #4  
Old January 22nd, 2005, 01:45 AM
John Spencer (MVP)
external usenet poster
 
Posts: n/a
Default

Can you post the query you are using? Or are you using one of the VBA aggregate
functions? A very basic query might look like:

SELECT Sum(IIF(SomeYN=True,1,0)) as CountYes,
Sum(IIF(SomeYN=False,1,0)) as CountNo,
Sum(IIF(SomeYN2=True,1,0)) as CountYes2,
Sum(IIF(SomeYN2=False,1,0)) as CountNo2,
FROM SomeTable


"Chris Motherwell via AccessMonster.com" wrote:

Thanks for the reply John.
Let's say the criteria is Yes for a Yes/No field. If there are no Yeses in the the data, is it possible to display a zero to show this result?

CM

--
Message posted via http://www.accessmonster.com

  #5  
Old January 22nd, 2005, 07:54 AM
Chris Motherwell via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

I had to nest the queries to get it to work - the Sum and Iif combined did the trick! Thanks a lot

Chris

--
Message posted via http://www.accessmonster.com
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Max Function on Count jk Running & Setting Up Queries 1 October 22nd, 2004 03:34 AM
Count function show zero when no record for an institution George in Waco General Discussion 1 October 12th, 2004 03:25 PM
Which function to use to count the records satisfying two criteria? Max Worksheet Functions 0 November 21st, 2003 07:59 AM
Count function Worksheet Functions 2 November 20th, 2003 07:16 PM


All times are GMT +1. The time now is 03:50 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.