I want a report like that friends:
id descrip codigo nro idingreso bien bueno regular malo
01 aceite 2345 2 23 a 3 4 1
02 azucar 2345 4 34 b 2 5 2
I'm trying something like that but I do not get it right, it turns out to be pure bad or it turns out to be pure good, please help me and if I add a new record if it was already bad the record goes there
SELECT
count(descripcion) as descr,
descripcion,codigo,
nro,
idingreso,
bien,
case when estado='BUENO' THEN count(estado) ELSE '' END as EB,
case when estado='REGULAR' THEN count(estado) else '' end as ER,
case when estado='MALO' THEN count(estado) else '' end AS EM
FROM detalleinventarioinicial
GROUP BY descripcion
ORDER BY nro,idingreso asc,descripcion asc