dbTalk Databases Forums  

Re: SQL - count(ID) problem

comp.database.ms-access comp.database.ms-access


Discuss Re: SQL - count(ID) problem in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
tom
 
Posts: n/a

Default Re: SQL - count(ID) problem - 09-03-2003 , 02:58 PM






Your dialect of SQL is recognized by Access, but is not standard for
access. i'm not sure how you do an Outer Join this way, but the
Access standard would have your query written:
SELECT tblGroups.groupID, groupName, count(paxID)
FROM tblGroups INNER JOIN tblPax ON tblGroups.groupID =
tblPax.groupID
GROUP BY tblGroups.groupID, groupName

to make this query return NULLs, you would change it to:
SELECT tblGroups.groupID, groupName, count(paxID)
FROM tblGroups LEFT JOIN tblPax ON tblGroups.groupID = tblPax.groupID
GROUP BY tblGroups.groupID, groupName

it will return NULLs, not 0s, so you will have to process them if you
want 0s.

hope that helps, tom


"Hamish McCracken" <mrshabby (AT) hotmail (DOT) com> wrote

Quote:
Hi. I have a problem that has been plaging me for a couple of days....
thought some one might be able to help....

I have 2 tables: tblGroups and tblPax.

My SQL statement is:

SELECT tblGroups.groupID, groupName, count(paxID)
FROM tblGroups, tblPax
WHERE tblGroups.groupID = tblPax.groupID
GROUP BY tblGroups.groupID, groupName

When tblPax has no groupID in it, the SQL above does not return any result
for groupID, but I need it to return a "Null" count similar to the tabloe
below.

groupID count(paxID)
1 0

But this is what I need it too do. I'm using ASP VBScript and an Access
database. I know how to retreive a count value of 0 in SQL Server and Oracle
but not in Access.

Can anyone help?

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.