List:General Discussion« Previous MessageNext Message »
From:Dan Bolser Date:April 11 2005 9:58am
Subject:Display 1st row of every group?
View as plain text  
I read with great interest this 

http://www.artfulsoftware.com/queries.php#4

Display 1st row of every group

SELECT id
FROM tbl
GROUP BY id
HAVING count(*) = 1;

I want to use this syntax with an 'order by' like this...

  SELECT *
    FROM tbl
GROUP BY id
  HAVING count(*) = 1
ORDER BY bleah;

Will this syntax return the row within the "id group" with the smallest
value of the bleah column? (is it guaranteed to do so?)

Cheers,
Dan.

Thread
Display 1st row of every group?Dan Bolser11 Apr
  • Re: Display 1st row of every group?Dan Bolser11 Apr
    • Re: Display 1st row of every group?Peter Brawley11 Apr
      • Re: Display 1st row of every group?Dan Bolser11 Apr
  • Re: Display 1st row of every group?Rhino11 Apr
    • Re: Display 1st row of every group?Dan Bolser11 Apr
      • Re: Display 1st row of every group?Peter Brawley11 Apr
        • Re: Display 1st row of every group?Dan Bolser11 Apr
          • Re: Display 1st row of every group?Peter Brawley11 Apr
            • Analyze TableEmmett Bishop11 Apr