Results 1 to 15 of 15
  1. #1
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10

    Question I need that my query show me all values, 0 or null included


    good night to all,

    I have a database with some tables. One of them is "Groups" and other "Types of failures"
    Click image for larger version. 

Name:	Consulta1.jpg 
Views:	17 
Size:	105.7 KB 
ID:	33261Click image for larger version. 

Name:	Consulta2.jpg 
Views:	17 
Size:	105.7 KB 
ID:	33262


    After collecting a lot of data, I need to export to Excel a table to calculate the average number of faults per group. And this is where I have the problem.

    In this query, I get all the failures and types of failures but I can not find the groups that have had 0 failures.

    Click image for larger version. 

Name:	Consulta3.jpg 
Views:	16 
Size:	128.2 KB 
ID:	33263


    This is what I get

    Click image for larger version. 

Name:	Consulta4.jpg 
Views:	16 
Size:	134.7 KB 
ID:	33264


    but this is what I want to get, with 0 values

    Click image for larger version. 

Name:	Consulta5.jpg 
Views:	16 
Size:	130.9 KB 
ID:	33265

    Do you know how I can get it?

    thank you very much everyone and greet regards

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Try outer joins between your tables (double click on the join line and change to option 2 or 3, probably for both tables). I wish I could be more specific, but not being able to read the text in the images is a problem for me. I'll guess that the left most join should point to the middle table, meaning you want "all groups" and those records which match where the fields were joined. The text hints you'll see when looking at the join descriptions should help a bit, although not always are they crystal clear to some. I suspect that for table fields that have no counts, you have 0 as a default value to ensure you at least have a record that the count/value is reported as being 0.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Alternatively create a second unmatched query listing all records from the first two tables where there is no matching data in the third and add a 'count' field with value =0
    Now create a UNION query using the first query and the new one.
    That's it

    The reason the images are unclear is that each contains lots of unnecessary parts of the screen with the section needed being tiny.
    In future please crop the images before uploading so the section we need is legible.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  4. #4
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    Many thanks. I am going tu try it.
    Sorry for the Photos
    Many thanks. I'm going to try it.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    If you have records in Base Vorcheck with 0 value then they should be showing. How did you get that Total field to show with 0's for each Grupo/Tipo combination?

    The query design does not show table Copia de Grupos but that table does seem to show the desired output. How is this table populated?

    You may need a dataset of all possible combinations of Grupo and Tipo de falko values. This can be accomplished with Cartesian query - every record of each table is joined to every record of other table:

    SELECT Grupos.*, Tipos_Falko.* FROM Grupos, Tipos_Falko;

    Then join Base Vorcheck table to that dataset with compound join.

    Cartesian query can perform very slowly with large dataset.

    The other option is to create records with 0 value in Base Vorcheck.

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.
    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.

  6. #6
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    Quote Originally Posted by June7 View Post
    If you have records in Base Vorcheck with 0 value then they should be showing. How did you get that Total field to show with 0's for each Grupo/Tipo combination?

    The query design does not show table Copia de Grupos but that table does seem to show the desired output. How is this table populated?

    You may need a dataset of all possible combinations of Grupo and Tipo de falko values. This can be accomplished with Cartesian query - every record of each table is joined to every record of other table:

    SELECT Grupos.*, Tipos_Falko.* FROM Grupos, Tipos_Falko;

    Then join Base Vorcheck table to that dataset with compound join.

    Cartesian query can perform very slowly with large dataset.

    The other option is to create records with 0 value in Base Vorcheck.

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.

    Thank you very much for your answers.

    Finally I have created a second table with values ​​at 0.

    Click image for larger version. 

Name:	Tabla1.png 
Views:	10 
Size:	19.1 KB 
ID:	33275


    and I've made a union query with the first table



    Click image for larger version. 

Name:	Tabla2.png 
Views:	10 
Size:	20.5 KB 
ID:	33277




    and it is the result. The union query creates new records but does not add the values ​​of the two tables.
    Click image for larger version. 

Name:	Tabla3.png 
Views:	10 
Size:	14.8 KB 
ID:	33276Click image for larger version. 

Name:	Table3B.png 
Views:	10 
Size:	22.9 KB 
ID:	33278


    Thank you so much for everything.


    it is the result. The union query creates new records but does not add the values ​​of the two tables.

  7. #7
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Two errors
    1. The query with zero values should only be for those records not in the main query. See my previous post.
    2. Remove the blank lines before and after the word UNION in the union query
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  8. #8
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    Quote Originally Posted by ridders52 View Post
    Two errors
    1. The query with zero values should only be for those records not in the main query. See my previous post.
    2. Remove the blank lines before and after the word UNION in the union query

    Thanks a lot Ridders.

    The problem that when I try to list the null values, I do not find any.

    Click image for larger version. 

Name:	Tabla2.png 
Views:	9 
Size:	18.4 KB 
ID:	33279Click image for larger version. 

Name:	tabla2b.png 
Views:	9 
Size:	6.7 KB 
ID:	33280

  9. #9
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Your query uses INNER joins so it only lists records found in each table
    So by definition searching for NULL will fail

    Unmatched queries MUST be done using outer joins - so that records in one table but not the other can be found
    Access has an unmatched query wizard - I suggest you use it for this purpose
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  10. #10
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    The SQL statement could not be executed because it contains ambiguous outer joins
    Error Description: The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement



    when I do this

    Click image for larger version. 

Name:	Table1.png 
Views:	9 
Size:	31.1 KB 
ID:	33281


    access generates this error


    Click image for larger version. 

Name:	Tabla2.png 
Views:	9 
Size:	33.4 KB 
ID:	33282

    The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement




    Do you know how I could solve this error?

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Your outer join arrow can't work the way you have set this up
    The complication is that you have 3 tables.

    The problem I have is not understanding the language in your screenshots
    Did you use the wizard?

    You either need an outer join in the same direction for both links where the table with NULL values in the count field is at the end of the arrow 'flow'
    OR possibly an inner join for the first two tables with an outer join to the table with NULL values in the count field so that is at the end of the arrow 'flow'.
    Hard to put into words - hopefully you can grasp what I mean

    If not post a stripped down version of your database explaining which tables & queries to look at
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  12. #12
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    Quote Originally Posted by ridders52 View Post
    Your outer join arrow can't work the way you have set this up
    The complication is that you have 3 tables.

    The problem I have is not understanding the language in your screenshots
    Did you use the wizard?

    You either need an outer join in the same direction for both links where the table with NULL values in the count field is at the end of the arrow 'flow'
    OR possibly an inner join for the first two tables with an outer join to the table with NULL values in the count field so that is at the end of the arrow 'flow'.
    Hard to put into words - hopefully you can grasp what I mean

    If not post a stripped down version of your database explaining which tables & queries to look at


    Thank you very much, I will try something of what you tell me. Great Regards.

  13. #13
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Quote Originally Posted by scumposse View Post
    Thank you very much, I will try something of what you tell me. Great Regards.
    Thank you very much, I will try something of what you tell me. a greeting
    I'm seeing double!!!

    Have a look at this post about ambiguous joins as it may help you understand what to do
    https://www.accessforums.net/showthr...356#post390356
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  14. #14
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    Quote Originally Posted by ridders52 View Post
    I'm seeing double!!!

    Have a look at this post about ambiguous joins as it may help you understand what to do
    https://www.accessforums.net/showthr...356#post390356

    hahahaha

    Thank you so much for everything. You have a nice dog!

  15. #15
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    You're welcome.
    Isla has the dogged approach to problem solving....
    Hopefully you'll be able to solve it now.
    If not, post your database.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Trying to show only Non Null Values on a report
    By adamtate94 in forum Reports
    Replies: 7
    Last Post: 09-07-2016, 10:09 AM
  2. Replies: 5
    Last Post: 03-08-2016, 07:25 AM
  3. Show null values in records
    By Nola-Edu in forum Queries
    Replies: 1
    Last Post: 04-10-2013, 12:36 PM
  4. show companies with null values
    By jamo in forum Programming
    Replies: 11
    Last Post: 11-06-2012, 08:11 AM
  5. Replies: 2
    Last Post: 08-01-2011, 09:30 AM

Tags for this Thread

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