On 8 March 2018 at 06:52, Andreas Dafferner
<andreas.daffer...@adw.uni-heidelberg.de> wrote:
> select distinct left (col, (length(col) - 9)) from table order by col

You could do this:

FixMyStreet::DB->resultset("Table")->search({}, {
    columns => { col => \"left(col, length(col)-9)" },
    distinct => 1,
    order_by => "left(col, length(col)-9)"  });

Run with DBIC_TRACE, the SQL for this is:
    SELECT left(col, length(col)-9) FROM table me GROUP BY left(col,
length(col)-9) ORDER BY left(col, length(col)-9):

And the resultant column is available as ->col for each row.


List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to