[Dbix-class] Hi All, First Question

Jess Robinson castaway at desert-island.demon.co.uk
Wed Oct 18 10:25:48 CEST 2006



On Tue, 17 Oct 2006, tiziano at e-tip.net wrote:

> Hi All,
> 've got a table, called estimate,containing 4 fields : id, ref, revision,
> status.
> id is the primary key,
> ref is the number of the estimate in format (number/year)
> revision is a int that specifies the revision of the estimate.
> Now... in table can be more than one rows with same ref but several
> revision numbers
> I've done something like resultset({ %search },{ group_by => [qw /ref /]}
> but in some cases this give me back the row with the lowest id for that
> group.
> Example:
> 1,1/2006,0,0  <--- this is the row returned by the query
> 2,1/2006,1,0
> 3,1/2006,3,0
> 4,1/2006,4,0
>
> but... i need the one with id = 4
> Any help on doing it?
> Thanks in advance
> Tiziano
>

Use select => and instead of just the plain columns, have: { max => 
'revision'} for that field.. which will get you the maximal revision 
number per ref.

Jess




More information about the Dbix-class mailing list