sql server 2008 - Two related queries needs to be one -
i know basic thing sql serious weak point of mine...
i have following query ("query1")
select sc.statues, sc_some_real_code [corpdb_gs].[dbo].[simple_codes] sc inner join [corpdb_gs].[dbo].[real_simple_essentials] rse on sc.statues = rse.se_statutes , sc.some_real_code = rse.se_statutes_reason
i need return rows in table [db2].[dbo].[statusyo]
statusyo.code = "query1".sc.statues , statusyo.reason = "query1".sc.some_real_code
help?
select * [db2].[dbo].[statusyo] query2 inner join (select sc.statues statues , sc.some_real_code some_real_code [corpdb_gs].[dbo].[simple_codes] sc inner join [corpdb_gs].[dbo].[real_simple_essentials] rse on sc.statues = rse.se_statutes , sc.some_real_code = rse.se_statutes_reason) query1 on query1.statues =query2.code , query1.some_real_code=query2.reason
this work you......
Comments
Post a Comment