2012-06-12 57 views
-1

我運行折舊數據庫。我需要爲下個月運行折舊兩個條件必須得到滿足,但是從不同的表來自兩個不同表格的條件

insert into Asset.dbo.depreciation (Asset_Tag, depreciation_date, Depreciation_Amount) 
    select 
     Asset_Tag, '2012-05-01', Depreciation_Amount 
    from Asset.dbo.depreciation 
    where depreciation_date = '2012-04-01' 
    and asset_details.Fully_Depreciated = 'N' 

條件的and後來自另一個表。

請幫

+3

你缺少加入到其他表前:'Asset.dbo.depreciation d INNER JOIN Asset.dbo。 Asset_details d2 ON d1.keycolumn = d2.keycolum' –

+0

@rs - 在別人之前寫下這個答案! –

回答

1

你缺少加入到其他表 例如:

Asset.dbo.depreciation d INNER JOIN Asset.dbo.Asset_details d2 ON d1.keycolumn = d2.keycolum where d.depreciation_date = '2012-04-01' and d1.Fully_Depreciated = 'N'

+0

已將答案
插入Asset.dbo.depreciation(Asset_tag,depreciation_date,depreciation_amount) 從Asset.dbo.depreciation join asset.dbo中選擇Asset.dbo.depreciation.Asset_tag,'2012-05-01',depreciation_amount。 asset_details depreciation.asset_tag = asset_details.asset_tag where depreciation_date ='2012-04-01'and Fully_Depreciated ='N'

相關問題