自学,首次海报。
我有什么似乎应该是基本的,但我有一个让大脑工作的障碍。我有两个数据集,我想将其中一个与另一个进行比较,并找到集合1(实际)中未设置为(操作费用)的记录。子查询上的SQL多重特征选择
select distinct vacctcode, vEntityID
from tm1_fin_lines_integration
where vScenario = '507'
and vLineItemType = 'OperatingExpense'
这将返回一个数据集,看起来像这样:
我的第二个查询:
select i.property_externalid, i.externalid, r.lineitemtypename
from ivw_Actuals i
inner join rvw_accounts r on r.accountnumber = i.externalid
where r.LineItemTypeName = 'OperatingExpense'
and i.PropertyAssetId in .
(select vpropid from tm1_fin_lines_integration where vScenario = '507')
并返回结果,如:
我想查找“实际数”结果集中不在“操作费用结果集”中的记录。我需要匹配externalid/vacctcode和vEntityid/Property_ExternalID。
我只是不确定如何匹配多个特征。
这个查询在我只查看一个vEntityid/Property_ExternalID时有效,但实际上我会查看数百个数据集,所以我需要能够找到位于其中的帐户代码/实体组合不在经营费用组中的实际数量。
select i.property_externalid,
i.externalid,
r.lineitemtypename
from ivw_Actuals i
inner join rvw_accounts r on r.accountnumber = i.externalid
where r.LineItemTypeName = 'OperatingExpense'
and i.PropertyAssetId in
(select vpropid from tm1_fin_lines_integration where vScenario = '507')
and i.externalid not in
(select distinct vacctcode, vEntityID
from
tm1_fin_lines_integration
where
vScenario = '507'
and vLineItemType = 'OperatingExpense')
您正在使用哪些DBMS? –
向我们展示样品数据和预期结果。不确定“实际数量”结果集中“不在”运营费用“”中的含义。 \t请阅读[**如何提问**](http://stackoverflow.com/help/how-to-ask) \t \t这里是[** START **]( http://spaghettidba.com/2015/04/24/how-to-post-at-sql-question-on-a-public-forum/)了解如何提高您的问题质量并获得更好的答案。 –