Results 1 to 2 of 2
  1. #1
    theracer06 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    7

    Avoiding duplicates in query


    Hi,

    I am trying to refine a query for a simulation I inherited. The query forms one duplicate for each row.

    In the picture attached are the three joined tables used for the query.

    What is wrong here?

    I tried Select Distinct, but it seems not to be working.

    SELECT [Load curves].[ID Country], Years.Year, [Load curves].Date, [Load curves].Time, [Load in MW]*[Annual Load increase] AS [Projected Load in MW], Years.Year-[Value] AS [Years difference], Year(Now()) AS [Current year], Parameters.Value
    FROM [Parameters], ([Load curves] INNER JOIN [Annual Load Increase] ON [Load curves].[ID Country]=[Annual Load Increase].[ID Country]) INNER JOIN Years ON [Annual Load Increase].Year=Years.Year;

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    make sure there is no duplicate values in the join fields.

    If you mean [Load in MW]*[Annual Load increase] are "duplicate" as your expectation(result is double/ triple), assume [Load in MW] and [Annual Load increase] are in table [load curves] then make sure [Annual Load Increase].[ID Country]) and Years.Year don't have duplicate values.

    And, you should not just put table Parameters in the query without any condition, this will general as many duplicate records as the number of records in parameter table.

    To make it easy to understand what I said, I give a simple example:

    Table AA Table BB
    A1, A2 B1 B2
    1 2 1 gg
    3 3 1 dd
    4 5

    There are duplicate value in BB.B1, so
    select AA.* from AA inner join BB on AA.a1=BB.b1
    will return 2 records as:
    A1 A2
    1 2
    1 2

    select AA.* from BB,AA
    will return 6 records:
    A1 A2
    1 2
    1 2
    3 3
    3 3
    4 5
    4 5

    Try to modify you query as what you understand.

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

Similar Threads

  1. Duplicates in Query
    By Dega in forum Queries
    Replies: 1
    Last Post: 05-02-2010, 05:09 PM
  2. Find Duplicates Query
    By mulefeathers in forum Queries
    Replies: 13
    Last Post: 04-22-2010, 05:39 PM
  3. combo box - no duplicates
    By pkg206 in forum Access
    Replies: 1
    Last Post: 11-12-2009, 10:41 AM
  4. How to remove duplicates
    By TonyBender in forum Access
    Replies: 0
    Last Post: 10-21-2009, 10:27 PM
  5. Pulling out duplicates
    By FREEEEEEDOM in forum Access
    Replies: 1
    Last Post: 04-21-2009, 10:37 PM

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