Título: [DUDA SQL] IF en SQL Script [RESUELTO] Publicado por: Reent en 4 Agosto 2020, 15:34 pm Hola a todos, estoy desde la mañana intentando hacer esto:
En el script hay un join de 4 tablas las cuales estan en join por sus ids, lo que busco es contar la cantidad de lugares donde hay una caja y la caja no tenga una orden, todo eso funciona. Lo que quiero aparte de eso es que los lugares ocupados por caja se multiplique por 2 si la caja es grande. aqui les dejo mi script: Código: select art.art_id , count(distinct lhm.place_id) from lhm, lhmdef lhmd, art, sector where lhm.lhmdef_id = lhmd.lhmdef_id and art.art_id = sector.art_id (+) and lhm.lhm_id = sector.lhm_id and lhm.lhmstat=1 and lhm.lag_id = 13 and lhm.order_id is null group by art.art_id order by 2 desc Script para entender mi idea mas facil: [RESUELTO] Código: select art.art_id , count(distinct(case when lhm.abmz > 300 then lhm.place_id * 2) from lhm, lhmdef lhmd, art, sector where lhm.lhmdef_id = lhmd.lhmdef_id and art.art_id = sector.art_id (+) and lhm.lhm_id = sector.lhm_id and lhm.lhmstat=1 and lhm.lag_id = 13 and lhm.order_id is null group by art.art_id order by 2 desc Saludos! |