[thelist] SQL - searching a history table

Matt Warden mwarden at gmail.com
Thu Oct 12 21:34:59 CDT 2006

On 10/12/06, Phil Turmel <philip at turmel.org> wrote:
> You didn't mention what DB platform, but they'll all be similar if they
> support subqueries.  Something like this:


> Select status, Count(widgetid) As wcount
>    From (Select status, widgetid, Max(date_updated) As date_lastupdated
>      Where date_updated Between '20060501' And '20060601'
>      Group By status, widgetid)
>    Group By status
>    Order By wcount Desc;

Very cool. I was using the max() subquery method that others
suggested. I hadn't thought of this.

Matt Warden
Cleveland, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list