Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 其中条件来自两个不同的表_Sql Server - Fatal编程技术网

Sql server 其中条件来自两个不同的表

Sql server 其中条件来自两个不同的表,sql-server,Sql Server,我正在运行折旧数据库。我需要运行下个月的折旧,其中必须满足两个条件,但来自不同的表 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

我正在运行折旧数据库。我需要运行下个月的折旧,其中必须满足两个条件,但来自不同的表

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'
后面的条件来自另一个表


请帮助

您缺少到其他表的联接 例:

Asset.dbo.折旧d内部联接Asset.dbo.Asset\u详细信息d2在d1.keycolumn=d2.keycolumn上,其中d.折旧日期='2012-04-01'和d1.Full\u折旧='N'

您缺少与其他表的联接,例如:
Asset.dbo.detainment d internal join Asset.dbo.Asset\u d1.keycolumn=d2上的d2详细信息。keycolumn
@rs-在其他人之前将其作为答案写入!得到答案
插入Asset.dbo.折旧(资产标签、折旧日期、折旧金额)选择Asset.dbo.折旧.资产标签,“2012-05-01”,折旧金额来自Asset.dbo.折旧加入Asset.dbo.Asset\u折旧详细信息。Asset\u标记=资产\u详细信息。Asset\u标记,其中折旧日期='2012-04-01',已完全折旧='N'