本文介绍了需要类似于JOIN的东西,但不完全一样。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 好的,这是我之前问过的一个问题,但从未找到我想要的答案。然而,当时我正在研究处理某些事情的方法,所以我会尝试将问题简化为一种特定方法的技术细节。无论如何... 假设我有一个表表1 ,其中字段 DateTime1 (日期/时间)。 我有一个表表2 ,其中字段已开始和已完成(均为日期/时间)。 (实际上,字段格式应与讨论无关)。 我想构建某种查询,如果可能的话,分组 DateTime1 中的值,并为每个值返回表2中记录数的计数 (已开始< = DateTime1和已完成> ; = DateTime1)。 换句话说,有点像简单的连接,但两个字段括号或环绕或环绕原始字段,而不是匹配它的一个字段。 可以吗?解决方案 您也可以尝试... SELECT DateTime1,Sum(IIf(DLookup(" [Started]" ;,Table2,[Started]< ="& [DateTime1])AND DLookup([Finished],Table2,[Finished]> ="& ; [DateTime1]),1,0)) FROM Table1 GROUP BY DateTime1; 我不是知道哪些会有更好的表现,但我猜测,因为阿德里安有一个完整的外部联盟我的会更好。也许我会赢得这个。虽然幸运的是它不会起作用。 别告诉我你在这个杀手上赢了这场战斗。 Mary Ok, this is a question I''ve asked here before, but never found the answer I was looking for. However, at that time I was investigating ways of approaching something, so I''ll try simplifying the question to the technical details of one specific approach. Anyway... Let''s say I have a table Table1 with field DateTime1 (date/time).And I have a table Table2 with fields Started and Finished (both date/time).(Actually, the field formats should be irrelevant to the discussion). I want to build some sort of query, if possible, which will group by the values in DateTime1, and for each value, return a count of the number of records in Table2 with (Started <= DateTime1 and Finished >= DateTime1).In other words, kind of like a simple join, but where two fields "bracket" or "surround" the original field, rather than one field matching it. Can do? 解决方案 You could also try ... SELECT DateTime1, Sum(IIf(DLookup("[Started]","Table2","[Started]<=" & [DateTime1]) AND DLookup("[Finished]","Table2","[Finished]>=" & [DateTime1]),1,0))FROM Table1GROUP BY DateTime1; I don''t know which will have the better preformance but I''m guessing that because Adrian''s has a full outer join mine will be better. Maybe I''ll win this one. Although with my luck it won''t work. Don''t tell me you''re winning the battle on this one Killer. Mary 这篇关于需要类似于JOIN的东西,但不完全一样。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 17:15