MYSQL-- Error Code: 1140

0

I need help with this error that marks me mysql and I do not understand what it means, and how I would have to solve it.

drop temporary table if exists MinP;  
create temporary table MinP
(select CantidadPS.cuil, min(CantidadPS.CantPrendas)
from
(select ps.cuil, count(*) as CantPrendas
from prendas_sastres ps 
inner join prendas p on p.nro_persona=ps.nro_persona 
and p.cod_tipo_prenda=ps.cod_tipo_prenda and p.nro_pedido=ps.nro_pedido
where fecha_fin_real is null and fecha_medicion is not null
group by ps.cuil)CantidadPS);

The Error that marks me is the following:

Error Code: 1140. In aggregated query without GROUP BY, expression #1 
of SELECT list contains nonaggregated column 'CantidadPS.cuil'; 
this is incompatible with sql_mode=only_full_group_by
    
asked by Maca Igoillo 19.08.2017 в 16:27
source

1 answer

0

Try doing it this way:

drop temporary table if exists MinP;  
create temporary table MinP
(select CantidadPS.cuil, min(CantidadPS.CantPrendas)
from (select ps.cuil, count(*) as CantPrendas
    from prendas_sastres ps 
    inner join prendas p 
        on p.nro_persona=ps.nro_persona 
        on p.cod_tipo_prenda=ps.cod_tipo_prenda 
        on p.nro_pedido=ps.nro_pedido
    where fecha_fin_real is null 
        and fecha_medicion is not null
    group by ps.cuil) as CantidadPS)
group by CantidadPS.cuil;

Greetings.

    
answered by 19.08.2017 в 16:51