Results 1 to 6 of 6
  1. #1
    Nadia111 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    3

    Only show data when two collumns are the same

    Hi,



    In the query I have made to much data is shown. I only want to see the data if the data in collumn year and Disyear are equal. Does somebody know how i can adjust this in the query I build?

    Hopefully somebody can help me,

    greetings Nadia

    ID Sex MinOfTerrnr MaxOfTerrnr Terr1 Terr2 Distance Year Disyear
    2 M 3 4 3 4 1 2008 2010
    2 M 3 4 3 4 1 2009 2010
    2 M 3 4 3 4 1 2010 2010
    2 M 3 4 3 4 1 2011 2010
    2 M 3 4 3 4 1 2012 2010
    11 F 2 13 2 13 1 2008 2009
    11 F 2 13 2 13 1 2009 2009
    11 F 2 13 2 13 1 2010 2009
    11 F 2 13 2 13 1 2011 2009
    11 F 2 13 2 13 1 2012 2009
    23 F 11 25 11 25 1 2008 2013
    23 F 11 25 11 25 1 2009 2013
    23 F 11 25 11 25 1 2010 2013
    23 F 11 25 11 25 1 2011 2013
    23 F 11 25 11 25 1 2012 2013
    26 F 10 38 10 38 1 2008 2011
    26 F 10 38 10 38 1 2009 2011
    26 F 10 38 10 38 1 2010 2011
    26 F 10 38 10 38 1 2012 2011
    44 F 18 71 18 71 1 2009 2009
    52 F 41 45 41 45 1 2008 2009
    52 F 41 45 41 45 1 2009 2009
    52 F 41 45 41 45 1 2010 2009
    52 F 41 45 41 45 1 2011 2009
    52 F 41 45 41 45 1 2012 2009
    53 F 37 52 37 52 1 2008 2009

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Please show the sql of your current query.

  3. #3
    Nadia111 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    3
    SELECT [Dispersal:all dispersers].BirdID, [Dispersal:all dispersers].Sex, [Dispersal:all dispersers].MinOfTerrnr, [Dispersal:all dispersers].MaxOfTerrnr, TerrDistMatrix.Terr1, TerrDistMatrix.Terr2, TerrDistMatrix.Distance, TerrDistMatrix.Year, [Dispersal:all dispersers].DispersalYear
    FROM TerrDistMatrix RIGHT JOIN [Dispersal:all dispersers] ON (TerrDistMatrix.Terr2 = [Dispersal:all dispersers].MaxOfTerrnr) AND (TerrDistMatrix.Terr1 = [Dispersal:all dispersers].MinOfTerrnr)
    GROUP BY [Dispersal:all dispersers].BirdID, [Dispersal:all dispersers].Sex, [Dispersal:all dispersers].MinOfTerrnr, [Dispersal:all dispersers].MaxOfTerrnr, TerrDistMatrix.Terr1, TerrDistMatrix.Terr2, TerrDistMatrix.Distance, TerrDistMatrix.Year, [Dispersal:all dispersers].DispersalYear
    HAVING ((([Dispersal:all dispersers].BirdID)<1000 Or ([Dispersal:all dispersers].BirdID)>1200))
    ORDER BY TerrDistMatrix.Distance;

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Instead of Right Join try Inner Join

  5. #5
    Nadia111 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    3
    yeah, but the right join is for the territories. However if a make an extra join between year and Dispersalyear Access tells me it is not able to show the query.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    OK, leave the right join and try this (untested) just before your Group By line

    WHERE TerrDistMatrix.Year = [Dispersal:all dispersers].DispersalYear

    If this doesn't work then

    -please tell us more about the database
    - show us your tables and relationships as jpg
    - post your database as a zip (remove anything confidential)

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

Similar Threads

  1. Only Show Last 7 Days of data
    By MFS in forum Queries
    Replies: 8
    Last Post: 04-05-2012, 01:25 PM
  2. Only Show Subreport with Data
    By jkirkman in forum Reports
    Replies: 11
    Last Post: 04-01-2012, 12:35 PM
  3. Show object only if data available
    By 1eye1vision in forum Forms
    Replies: 41
    Last Post: 07-30-2011, 02:44 PM
  4. Subform will not show data
    By Brian62 in forum Forms
    Replies: 2
    Last Post: 02-19-2010, 10:43 AM
  5. how to show all data in this querey
    By grad2009 in forum Queries
    Replies: 3
    Last Post: 02-08-2010, 07:35 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