Hola,
tengo una query de la siguiente manera:

Select t1.pd_id,count(t2.pc_id) as truta,t2.pr_id from p_d t1 left outer join 
p_c t2 on t1.pd_id=t2.pd_id where (t1.pov_id = 805 or t1.pd_zona='2' or 
t1.pd_zona='3' or t1.pd_zona='7') and t2.pbv_id = 805 and t2.pc_tipocli = 1 and 
t2.pr_id < 11 and t2.pc_d5 < '01/02/2014' and t2.pc_pc between 0 and 999 group 
by t1.pd_id,t2.pr_id order by t1.pd_id,t2.pr_id

Bien esta me devuelve sólo tuplas donde t1.pd_id=t2.pd_id ??? es un left outer 
join, debería devolver todas las tuplas de la tabla p_d que cumplan que la 
condición (t1.pov_id = 805 or t1.pd_zona='2' or t1.pd_zona='3' or 
t1.pd_zona='7') y las que no se crucen con valores de la tabla p_c debería 
devolver por ejemplo:
490,null,null
Por lo menos así lo hace la base de datos desde donde estoy migrando.

De hecho si lanzo la consulta:
Select t1.pd_id,count(t2.pc_id) as truta,t2.pr_id from p_d t1 left outer join 
p_c t2 on t1.pd_id=t2.pd_id where  t2.pbv_id = 805 and t2.pc_tipocli = 1 and 
t2.pr_id < 11 and t2.pc_d5 < '01/02/2014' and t2.pc_pc between 0 and 999 group 
by t1.pd_id,t2.pr_id order by t1.pd_id,t2.pr_id

o así:
Select t2.pd_id,count(t2.pc_id) as truta,t2.pr_id from p_d t1 left outer join 
p_c t2 on t1.pd_id=t2.pd_id where (t1.pov_id = 805 or t1.pd_zona='2' or 
t1.pd_zona='3' or t1.pd_zona='7') and t2.pbv_id = 805 and t2.pc_tipocli = 1 and 
t2.pr_id < 11 and t2.pc_d5 < '01/02/2014' and t2.pc_pc between 0 and 999 group 
by t2.pd_id,t2.pr_id order by t2.pd_id,t2.pr_id
el resultado es el mismo ??? yo por lo que he visto en otros gestores de bd 
esto funciona mal en postgresql. No hace caso al left outer join, está haciendo 
un join normal

Versión de postgresql 9.3.4 sobre w2008 Rc2 server Saludos

Responder a