recordset duplicates

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default recordset duplicates

    I have a query that brings back the same records more than once depending on
    how many entry's are in the table based on a non-unique ID. This is exactly
    how I want the table set up, but I only want the recordset to have just one of
    these ID's to be brought back so that I can populate a summary table which will
    not distinguish between these duplicates.

    Here is some background on what I am trying to accomplish if needed:

    I am creating a reporting database in which a primary user is selected but not
    necessarily the user logged in (i.e Secretary) My form also brings in as many
    secondary authors as the user inputs which also doesn't have to have the
    secretary's ID in it. I record the actual maker in the tblEOW so that a
    secretary entering information is associated with the report even though they
    are not a primary or secondary author. These primary and secondary authors are
    recorded into a tblAuthorEOW table which gives me the one to many relationship
    for multiple authors. Now that I have the data I wanted to show a summary to
    the user logged in of every report that they have made but not necessary an
    primary or secondary author hence the Union statement in the query. The query
    returns the correct entries but as many times as there are programsID's that
    are associated with the EOWRID. Since the summary will not include which
    program a report is connected to, I only need to return one PromgramID for each
    different EOWRID.

    I was wondering if there was something wrong with my query because I thought
    the group by syntax would take care of this issue. Also is there a more
    efficient way to get the information I want? How would I correct this recordset
    duplication?

    Thanks you for your time
    -Jeff D




    <cfquery name="GetEOW" datasource="WEARS">
    (SELECT Title, Date, Input, Engineer, Username, Program, tblEOWR.EOWRID
    , COUNT(tblProgramEOWR.ProgramID) AS NumProgramPerEOW
    , COUNT(tblAuthorEOWR.AuthorID) AS NumAuthors

    FROM
    tblEOWR, tblAuthorEOWR, tblProgramEOWR, tblProgram, tblAuthor

    WHERE tblEOWR.Engineer = '#Session.Username#'
    AND tblAuthorEOWR.EOWRID = tblEOWR.EOWRID
    AND tblAuthorEOWR.AuthorID = tblAuthor.AuthorID
    AND tblProgramEOWR.EOWRID = tblEOWR.EOWRID
    AND tblProgramEOWR.ProgramID = tblProgram.ProgramID
    GROUP BY
    tblEOWR.EOWRID,
    Date,
    Title,
    Engineer,
    Program
    )
    UNION
    (SELECT Title, Date, Input, Engineer, Username, Program, tblEOWR.EOWRID
    , COUNT(tblProgramEOWR.ProgramID) AS NumProgramPerEOW
    , COUNT(tblAuthorEOWR.AuthorID) AS NumAuthors

    FROM
    tblEOWR, tblAuthorEOWR, tblProgramEOWR, tblProgram, tblAuthor

    WHERE tblAuthorEOWR.AuthorID = #Session.AuthorID#
    AND tblEOWR.EOWRID = tblAuthorEOWR.EOWRID
    AND tblEOWR.EOWRID = tblProgramEOWR.EOWRID
    AND tblProgram.ProgramID = tblProgramEOWR.ProgramID
    GROUP BY
    tblEOWR.EOWRID,
    Date,
    Title,
    Engineer,
    Program)

    ORDER BY Date
    </cfquery>

    jedale Guest

  2. Similar Questions and Discussions

    1. SQL Duplicates
      Hi all, I'm facing the next problem: I've got a table like this: Name Size Total Martens 200 2 Martens 300 ...
    2. RecordSet.Move or RecordSet.AbsolutePosition??
      Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to...
    3. Eliminating duplicates
      Hi, I have a view with the following columns: member_rating_id ,rating_table_id ,member_id ,screen_name ,rating_value ,number_won...
    4. counting duplicates
      Jane, SELECT field1,count(field1) 'Counter' FROM <tgablename> GROUP BY field1 -- Dinesh. SQL Server FAQ at http://www.tkdinesh.com
    5. No Duplicates
      Is there a way so you make filemaker not accept any duplicate enteries into a certian fields ie; UserName: <field> Is there a way to make it...
  3. #2

    Default Re: recordset duplicates

    Well it looks like I stumbled across part of my answer doesn't include the
    union statement and it only has the EOWRID in the group by term. I realized
    that they only need to see the EOW's they made and not the one's others made
    and had their name in as an author. This will be taken care of on a separate
    search page.

    -Jeff

    jedale Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139