Finding minimum thro' recursion

Analytics

Finding minimum thro' recursion

Hi,

    Is there any possible way to findout minimum in foll. case thro' SQL Script or Stored procedure. I have two tables TX11 and MX11. I need to take the rec. from TX11 tbl and insert into MX11 tabl with foll. cond.

Assume 





TX11 (table)  
id SVC_id
301 1001
101 1001
201 1005
401 1006
301 1002
401 1002
101 1000




MX11 (Table)  
id SVC_id
101 1000
201 1005
301 1000
401

1000

Here we need to consider the minimum for each Id but for ex. consider 401 ID. 401 min. is 1002. Check 1002 in TX11 table. 1002 is repeating for 301. 301 min. is 1001. Again check,  1001 available to any other ids. id 101 contain 1001. For 101 id minimum is 1000. 1000 is not repeating anywhere. So 1000 need to insert into MX11 table for 401 ID.

Anyone pls help here to write SQL Script? Thanks in Advance...

-Ramesh