Oracle inner query -
my query
select kc.prod_id, kc.prod_actv_ts kit_cmpnt kc ,kit_cmpnt_stock kcs, prod p kc.cmpnt_cd='016' , kcs.kit_cmpnt_nbr= kc.kit_cmpnt_nbr , kcs.stock_id=1 , kcs.prod_id=kc.prod_id , kcs.prod_actv_ts=kc.prod_actv_ts , p.prod_id= kc.prod_id , p.prod_actv_ts= kc.prod_actv_ts , p.prod_inactv_ts null;
i want distinct combination of kc.prod_id, kc.prod_actv_ts
like distinct(kc.prod_id, kc.prod_actv_ts)
but getting combination of repeated prod_id , prod_actv_ts
please help
i'd restructure query follows :
select kc.prod_id, kc.prod_actv_ts kit_cmpnt kc kc.cmpnt_cd='016' , exists (select 1 kit_cmpnt_stock kcs kcs.stock_id=1 , kcs.kit_cmpnt_nbr= kc.kit_cmpnt_nbr , kcs.prod_id=kc.prod_id , kcs.prod_actv_ts=kc.prod_actv_ts) , exists (select 1 prod p p.prod_id= kc.prod_id , p.prod_actv_ts= kc.prod_actv_ts , p.prod_inactv_ts null);
general principle shouldn't have in clause unless taking it. if aren't taking it, filter , should in clause subquery.
Comments
Post a Comment