NYCPHP Meetup

NYPHP.org

[nycphp-talk] [OT] SQL Query

drydell at optonline.net drydell at optonline.net
Mon Feb 4 12:53:17 EST 2008


select id, max(version) from table group by id----- Original Message -----From: Ben Sgro Date: Monday, February 4, 2008 12:33 pmSubject: [nycphp-talk] [OT] SQL QueryTo: NYPHP Talk > Hello All,> > I have a table that includes an id (not unique and a version).> > A unique row is identified by both the id and version. This is > for MSSQL.> > I want to select all the id's, but only return the most up to > date version.> > So, for a table> > id | version> -------------> 1 | 0> 1 | 1> 2 | 0> 2 | 1> 2 | 2> > The query should return> > id | version> -------------> 1 | 1> 2 | 2> > Any help much appreciated.> > - Ben> _______________________________________________> New York PHP Community Talk Mailing List> http://lists.nyphp.org/mailman/listinfo/talk> > NYPHPCon 2006 Presentations Online> http://www.nyphpcon.com> > Show Your Participation in New York PHP> http://www.nyphp.org/show_participation.php> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080204/48b31c60/attachment.html>


More information about the talk mailing list