Good morning kiddies,have a look at the following code:select th.tkt_no,rl.item_no,rl.qty_recvd,rl.recvd_cost,rl.po_no,rl.commnt_1from po_recvr_hist_lin rljoin ps_tkt_hist thon rl.commnt_1=th.orig_ord_noright outer join ps_tkt_hist_lin tlon th.tkt_no=tl.tkt_noand th.str_id=tl.str_idand th.sta_id=tl.sta_idwhere (th.is_svc_call='Y' or th.is_svc_call='c')and rl.qty_recvd>=1and rl.item_no not in (select item_no from ps_tkt_hist_lin)group by th.tkt_no,rl.item_no,rl.qty_recvd,rl.recvd_cost,rl.po_no,rl.commnt_1
This query is returning the data that we want in our test db, but I am concerned about the subquery. It seems to me that the subquery is not specific enough. Does it need to contain the same join for the tables as in the main query, or am I over-reading this? (Not like that happens more than once a day!)Or, is there a more efficient way to write this
we are looking for all items in table rl that were recieved for an order (table th orig_ord_no) but not sold on that order (rl.item_no does not exist in tl.item_no)AndyThere's never enough time to type code right, but always enough time for a hotfix...