gudipadi
Starting Member
1 Post |
Posted - 2012-01-14 : 09:01:23
|
Table_1(custid,store,amont)Insert into Table_1 values (1,store1,1000)Insert into Table_1 values (2,store2,2000)Insert into Table_1 values (3,store3,3000)Insert into Table_1 values (4,store4,4000)Table_2 (store,product,col3,col4...)Insert into Table_2 values(store1,prod1,value)Insert into Table_2 values(store1,prod2,value)Insert into Table_2 values(store1,prod3,value)Insert into Table_2 values(store2,prod1,value)Insert into Table_2 values(store2,prod5,value)Insert into Table_2 values(store3,prod4,value)Insert into Table_2 values(store3,prod2,value)Insert into Table_2 values(store3,prod6,value)Insert into Table_2 values(store4,prod6,value)Insert into Table_2 values(store4,prod1,value)Insert into Table_2 values(store4,prod2,value)select custid,store,Amountfrom Table_1 where store not in (select store from table_2 where product != 'prod6')custid, store, amount---------------------1,store1,10002,store2,2000I need a query to get the same output in a more optimized way....because i have 500 millions in Table_1 and 700 millions of rows in Table_2Please help me out it is a production issue, need to fix this asap |
|