Results 1 to 3 of 3
  1. #1
    ScaniaJP is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    3

    Search query not showing all results/results with a 0 count

    Hello,

    I am creating a database that shows the amount of transactions done by employees of my company.
    I use one table from which I filter the things I need via a query which are the date of yesterday, employee number and their name.

    The criteria I use is under the employee number and I enter
    Code:
    Like [Pick1] Or Like [Pick2]
    to fill in whose numbers I need.
    After this I use a second query to give me the count of transactions per employee number.

    The problem now is that if Pick1 has for example 10 transactions and Pick2 has none I only see Pick1 having 10 but Pick2 doesn't show at all.

    I would like to be able to also see Pick2 having 0 transactions, like the following:
    Pick1 - 10
    Pick2 - 0

    Here is the SQL
    Code:
    SELECT [Gisteren binperf all].Picknummer, Count([Gisteren binperf all].FULLNAME) AS CountOfFULLNAME
    FROM [Gisteren binperf all]
    GROUP BY [Gisteren binperf all].Picknummer;
    The Picknummer is the employee number which is Grouped and then the FULLNAME shows their name which is Counted.


    As I said this works fine if the person has made transactions but if they have none nothing shows up in the table at all.

    I hope this is clear to you and that you could help me out.


    Thanks in advance!

    JP

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,915
    Using LIKE without wildcard is meaningless, just use = sign.

    If there is no data then there is nothing for the query to display. You would need a dataset of all possible employee and date combinations. In your case this query might do it:

    SELECT EmpID, Date()-1 AS Yesterday FROM Employees;

    Then join that query to the transactions table joining on EmpID and TransDate fields (compound join) with join type 'show all records from [empID/yesterday query] and only those from [transactions] that match', apply pick filter and build your counts from there.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Date()-1 may not return yesterday's date.

    If not use dateadd("d",-1, date())




    Sent from my iPhone using Tapatalk

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

Similar Threads

  1. Not all results showing in query
    By lewis1682 in forum Queries
    Replies: 3
    Last Post: 09-08-2013, 03:16 PM
  2. Replies: 12
    Last Post: 08-17-2013, 11:49 PM
  3. Query results showing table relationship
    By Steven.Allman in forum Queries
    Replies: 2
    Last Post: 04-23-2012, 01:31 PM
  4. Replies: 1
    Last Post: 03-09-2011, 02:04 AM
  5. Query showing unexpected results
    By johnmerlino in forum Queries
    Replies: 30
    Last Post: 10-25-2010, 07:08 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