none
subquery in group by

    Question

  • Hi,

    I m trying to find some duplicate rows with the condition that duplicate row will have its time within 60 secs of original row...

    But whn I ran query, I get error :

    "Cannot use an aggregate or a subquery in an expression used for the group by list of a GROUP BY clause.

    • Edited by Me.Saqib Wednesday, September 14, 2011 7:48 PM
    Wednesday, September 14, 2011 7:26 PM

Answers

All replies

  • Can you please post your table definition, sample data, and expected results?
    MG.-
    Mariano Gomez, MIS, MCITP, PMP
    IntellPartners, LLC.
    http://www.intellpartners.com/
    Blog http://dynamicsgpblogster.blogspot.com/
    Wednesday, September 14, 2011 7:32 PM
  • I have this problem solved in my blog post (first problem)

    Interesting T-SQL problems


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog
    • Marked as answer by Me.Saqib Thursday, September 15, 2011 9:57 PM
    Wednesday, September 14, 2011 7:33 PM
  • I dont have ID col in my table... will your solution still work? or Can I use row_number function inside CTE? 

    Wednesday, September 14, 2011 7:48 PM
  • Do you have any field(s) making each entry unique? Without some you may want to use row_number() function inside CTE and slightly modify that solution.
    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog
    Wednesday, September 14, 2011 8:40 PM
  • Post DDL and the code. We cannot read your mind.

     


    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL
    Wednesday, September 14, 2011 11:31 PM