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行也..请帮助我
答案 0 :(得分:0)
你可以试试这个:
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
实际上内部的select语句用括号括起来