<div dir="ltr"><div><div>The duplication of the column in the select, though it appears to be a bug, shouldn't really be a problem as you are not adding any new entities that can be identified as "quantity". <br><br>There is a problem in the general statement generated as, at least in the versions of SQL that I remember, it makes no sense to select distinct values of columns in a set grouped by another column. That is, in order to be meaningful in the traditional sense the only columns other than the group-by columns you can include would be sum(column), avg (column), etc. <br><br></div>Given the error that mysql provides it would appear that it is okay with this, so it has some other interpretation of the statement. I know that SQL Server and Sybase had something like this but it never made much sense to me and wasn't a part of the ANSI standard of the time. <br><br></div>The only way to correct this that I can think of is to remove all the columns from the result set and perhaps add the constant 1 or even sum(1) which would give you your result without the count (unless the ->count gives you the number of distinct quantities in which case it should still work).<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 10 October 2017 at 15:12, Vladimir Melnik <span dir="ltr"><<a href="mailto:v.melnik@uplink.ua" target="_blank">v.melnik@uplink.ua</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you, Gerhard!<br>
<br>
It was almost the first thing I tried, but it hadn't help. :-)<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Oct 10, 2017 at 04:26:21PM +0200, Gerhard Jungwirth wrote:<br>
> just guessing, did you try<br>
><br>
> group_by => [ 'me.quantity' ]<br>
><br>
><br>
> On 2017-10-10 13:20, Vladimir Melnik wrote:<br>
> > Dear colleagues,<br>
> ><br>
> > Here's a little snippet of the code:<br>
> > $resultset<br>
> > ->search(undef, { group_by => [ qw(quantity) ] })<br>
> > ->count;<br>
> ><br>
> > It produces the following exception:<br>
> > DBI Exception: DBD::mysql::st execute failed: Duplicate column name 'quantity' [for Statement "SELECT COUNT( * ) FROM (SELECT <a href="http://me.id" rel="noreferrer" target="_blank">me.id</a>, me.valid_from, me.valid_till, me.removed, me.provisioning_agreement_id, me.resource_piece_id, me.service_type_id, me.service_level_id, me.quantity, me.quantity FROM provisioning_obligation me GROUP BY quantity) me"] at /home/mmkeeper/perl5/perlbrew/<wbr>perls/perl-5.24.0/lib/site_<wbr>perl/5.24.0/DBIx/Class/Schema.<wbr>pm line 1118.<br>
> ><br>
> > What is the best way to avoid that?<br>
> ><br>
> > Thanks in advance!<br>
> ><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" rel="noreferrer" target="_blank">http://lists.scsys.co.uk/cgi-<wbr>bin/mailman/listinfo/dbix-<wbr>class</a><br>
> IRC: <a href="http://irc.perl.org#dbix-class" rel="noreferrer" target="_blank">irc.perl.org#dbix-class</a><br>
> SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" rel="noreferrer" target="_blank">http://dev.catalyst.perl.org/<wbr>repos/bast/DBIx-Class/</a><br>
> Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" rel="noreferrer" target="_blank">http://www.grokbase.com/group/<wbr>dbix-class@lists.scsys.co.uk</a><br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
V.Melnik<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" rel="noreferrer" target="_blank">http://lists.scsys.co.uk/cgi-<wbr>bin/mailman/listinfo/dbix-<wbr>class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" rel="noreferrer" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" rel="noreferrer" target="_blank">http://dev.catalyst.perl.org/<wbr>repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" rel="noreferrer" target="_blank">http://www.grokbase.com/group/<wbr>dbix-class@lists.scsys.co.uk</a><br>
</div></div></blockquote></div><br></div>