declare @table1 table (sno int,transferbirds int,noofbirds int,numofbirds int,mortality int)
insert into @table1
select sno,Branch,isnull((select transferbirds from K_RT_RetailsDetails where branch in (PN.sno),0) as Totalbirds,
isnull(select noofbirds from K_RT_WarehouseDetails where branch in (PN.sno),0) as Meatbirds,
isnull(select noofbirds from K_RT_MasterBirdsTransferDet where frombranch in (PN.sno),0) as TransferBirds,
isnull(select mortality from K_RT_DailyEntry where branch in (PN.sno),0)as Mortality,
isnull(select noofbirds from K_RT_BirdsTransfer where branch in (PN.sno),0) as Tobranchtransferbirds
from K_RT_MasterRetailStores PN
select * from @table1
我得到错误,'''附近语法不正确。 1号线,2号线,3号线,4号线also..please帮我连接多个表?
不能使用'ISNULL(SELECT a FROM b,0)'你需要在整个子查询中放置'()'...... ISNULL((SELECT a FROM b),0)'。你开始为第一个子查询*(你有'('但不是')')* – MatBailie
现在你有语法错误。修复这个问题后你再次得到错误,因为你的子查询可以返回多于一行。为什么不简单地使用K_RT_MasterRetailStores连接每个表PN – KumarHarsh