Results 1 to 4 of 4
  1. #1
    daffykyle is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    2

    Include zero values in below query!

    Hello all,

    I'm busy doing some querying for a project I'm working on and need to include zero values in this query I've been beavering away on.

    In summary the query brings up Emails, Phone Calls and Clicks for some clients based on their name, however in instances where the Email count is zero it isn't bringing up their stats even if they have a click count and a phone call count.

    Can anybody help please? (and Thanks in advance) Query wording below:

    SELECT DISTINCT JanuaryClients.Supplier, Nz(Count(JanuaryEmail.Supplier),0) AS Emails, Nz(JanuaryPhone.[Answered Calls],'0') AS Phone, Nz(DSum("Clicks","JanuaryClicks","[Action] like '*" & JanuaryClients.Tracking & "*'"),0) AS SumOfClicks
    FROM JanuaryEmail INNER JOIN (JanuaryPhone INNER JOIN JanuaryClients ON JanuaryPhone.Number = JanuaryClients.Premium) ON JanuaryEmail.Supplier = JanuaryClients.Supplier
    GROUP BY JanuaryClients.Supplier, JanuaryPhone.[Answered Calls], JanuaryClients.Tracking;

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Maybe...

    Quote Originally Posted by daffykyle View Post
    Hello all,

    I'm busy doing some querying for a project I'm working on and need to include zero values in this query I've been beavering away on.

    In summary the query brings up Emails, Phone Calls and Clicks for some clients based on their name, however in instances where the Email count is zero it isn't bringing up their stats even if they have a click count and a phone call count.

    Can anybody help please? (and Thanks in advance) Query wording below:

    SELECT DISTINCT JanuaryClients.Supplier, Nz(Count(JanuaryEmail.Supplier),0) AS
    count(Nz(JanuaryEmail.Supplier),0) AS
    Emails, Nz(JanuaryPhone.[Answered Calls],'0') AS Phone, Nz(DSum("Clicks","JanuaryClicks","[Action] like '*" & JanuaryClients.Tracking &
    The NZ(DSum needs to be switched also
    "*'"),0) AS SumOfClicks
    FROM JanuaryEmail INNER JOIN (JanuaryPhone INNER JOIN JanuaryClients ON JanuaryPhone.Number = JanuaryClients.Premium) ON JanuaryEmail.Supplier = JanuaryClients.Supplier
    GROUP BY JanuaryClients.Supplier, JanuaryPhone.[Answered Calls], JanuaryClients.Tracking;
    You have to resolve the nulls before you do anything else.

  3. #3
    daffykyle is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    2
    Hi Hertford, unfortunately this didnt seem to work.

    Access suggests that not enough arguments were in the statement, so i changed the Nz to be in front of count again and the query ran, just didnt allocate the 0 to the counts where it couldn't find that supplier name.

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    If it still isn't working, you might try setting up the query in design view

    with each of the fields replaced by a NZ calculated field. After you get it working, go to SQL view and get the SQL.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Include expressions in table
    By siedne in forum Database Design
    Replies: 2
    Last Post: 10-11-2011, 04:34 PM
  2. Include Multiple Records in Email
    By gopherking in forum Programming
    Replies: 3
    Last Post: 09-21-2011, 09:29 AM
  3. Only include unique occurances
    By filla_dilla in forum Queries
    Replies: 8
    Last Post: 07-18-2011, 10:22 PM
  4. Replies: 10
    Last Post: 12-11-2010, 11:01 PM
  5. include zero data where no record
    By Sandy Gomez in forum Access
    Replies: 4
    Last Post: 09-15-2010, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums