Re: Display duplicate rows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Plamen Ratchev

    Re: Display duplicate rows

    What happens when you add the column WQR_TDH_HEADER_ ID to both SELECT and
    GROUP BY? If you get rows you consider non-duplicate show as duplicate, then
    most likely your grouping does not include all significant columns to
    consider one row unique.

    HTH,

    Plamen Ratchev


  • Charlie

    #2
    Re: Display duplicate rows

    I would like to group by fewer columns, but I get an error trying to
    compile.
    As an example, eleminating the SHIFT column from group by gives the
    following error:

    Msg 8120, Level 16, State 1, Procedure PWQR_Select_Tea rdown_15_Day_Su mmary,
    Line 26

    Column 'TWQRHISTEARDOW N_HEADER.WQR_TD H_SHIFT_X' is invalid in the select
    list because it is not contained in either an aggregate function or the
    GROUP BY clause.



    "Plamen Ratchev" <Plamen@SQLStud io.comwrote in message
    news:HZ6dneA9cv KKurbVnZ2dnUVZ_ t_inZ2d@speakea sy.net...
    What happens when you add the column WQR_TDH_HEADER_ ID to both SELECT and
    GROUP BY? If you get rows you consider non-duplicate show as duplicate,
    then most likely your grouping does not include all significant columns to
    consider one row unique.
    >
    HTH,
    >
    Plamen Ratchev
    http://www.SQLStudio.com

    Comment

    • Plamen Ratchev

      #3
      Re: Display duplicate rows

      Actually I mean the opposite, you may need to add more columns to both
      SELECT/GROUP BY to get correct results.

      You do need to have the columns in the SELECT list as part of the GROUP BY
      clause.

      HTH,

      Plamen Ratchev


      Comment

      • Charlie

        #4
        Re: Display duplicate rows

        I am kind of new to this. Does each column in SELECT require a GROUP BY? I
        am getting an error if I don't include all SELECT columns in GROUP BY
        columns. I only need to group by around four columns, but need to display
        all columns in SELECT.

        Thanks for the help.

        Charlie

        "Plamen Ratchev" <Plamen@SQLStud io.comwrote in message
        news:OMidnVEIo6 nSsrbVnZ2dnUVZ_ vudnZ2d@speakea sy.net...
        Actually I mean the opposite, you may need to add more columns to both
        SELECT/GROUP BY to get correct results.
        >
        You do need to have the columns in the SELECT list as part of the GROUP BY
        clause.
        >
        HTH,
        >
        Plamen Ratchev
        http://www.SQLStudio.com

        Comment

        • Plamen Ratchev

          #5
          Re: Display duplicate rows

          I actually already listed aggregate functions: "...only grouping columns,
          aggregate functions, or constant expressions..." .

          Plamen Ratchev


          Comment

          Working...