dear all
i have tables(aztrd) it conatis invoice deatils like itm_code , date,loc_cd ..... ect
- in each in invoice they are itmes (itm_cd) from loc_cd "1" or loc_cd "2" and some invocies has items from loc_cd "1" only or loc_cd "2" only
i try this query to get only invoive number that has only one LOC_CD ( all items in invoive must be the same LOC_CD) but i got all invoice number - so how can i get only the invoice that has all items from on LOC_CD ( 1 for example ? )
SELECT tr_no,loc_cd FROM AZTRD
WHERE LOC_CD = 1 and tr_ty = 102 and loc = 01 AND LOC_CD NOT IN (SELECT itm_cd WHERE LOC_CD = 2)
GROUP BY TR_NO,LOC_CD
ORDER BY TR_NO
i have attach database backup has only table AZTRD to let you help me it works on SQL 2012 ... thanks a lot