sql - How compare two int list, resultset? -
i have 2 list of integer in resultset in query, ex: list_1: 11,16,28... list_2 11,16,19.. how can compare 2 list in condition?? condition if list different, make select.
this code:
select cosechaanterior.c_fk_idboleta 'boleta_p16', cosechaanteriordestino.c_fk_idboleta 'boleta_p17' clt_cosechaanterior cosechaanterior inner join clt_cosechaanteriordestino cosechaanteriordestino on cosechaanterior.si_fk_iddesglose = cosechaanteriordestino.si_fk_iddesglose inner join blt_boleta boleta on cosechaanterior.c_fk_idboleta = boleta.c_pk_idboleta --boleta.c_pk_idboleta = 44990112--@id_boleta (select si_fk_iddesglose clt_cosechaanteriordestino cosechaanteriordestino substring(cosechaanteriordestino.c_fk_idboleta,5,4) = '0112' , cosechaanteriordestino.c_fk_idboleta = 44990112) (select si_fk_iddesglose clt_cosechaanterior cosechaanterior substring(cosechaanterior.c_fk_idboleta,5,4)= '0112' , cosechaanterior.c_fk_idboleta = 44990112)
you want join, rather in clause. little unclear question 2 lists are. answer gives general solution.
assume lists in two-column format (, ), list consists of multiple values. following query returns ids have same set of values:
select list1.id (<subquery 1>) list1 full outer join (<subquery 2>) list2 on list1.id = list2.id , list1.val = list2.val group list1.id having max(case when list1.id null 1 else 0 end) = 0 , max(case when list2.id null 1 else 0 end) = 0 (this formulation assumes there no duplications in values.)
this doing full outer join , selecting ids have no null values on either side of join. null value generated on full outer join when elements not match.
Comments
Post a Comment