SELECT a.*,b.[no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time
给你写一个看看是不是这样效果
#4
SELECT a.ID,b.min_time,a.max_time,SUM(b.[no]) AS [no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time GROUP BY a.ID,b.min_time,a.max_time
#5
该回复于2016-05-23 13:15:09被管理员删除
#6
日期比较应该加上 “=”
#7
这是日期范围交集的用法,你没看懂
#8
SELECT a.ID,b.min_time,a.max_time,SUM(b.[no]) AS [no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time GROUP BY a.ID,b.min_time,a.max_time
日期比较应该加上 “=”
这是日期范围交集的用法,你没看懂
学习中
#1
时间有交叉时成不成立?
如:
01-01 05-01--A
02-01 06-01--B
结果是只显示B表,数量用不用汇总
#2
表A的时间作为条件,在这之间的表B的no总数
#3
SELECT a.*,b.[no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time
给你写一个看看是不是这样效果
#4
SELECT a.ID,b.min_time,a.max_time,SUM(b.[no]) AS [no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time GROUP BY a.ID,b.min_time,a.max_time
#5
该回复于2016-05-23 13:15:09被管理员删除
#6
SELECT a.ID,b.min_time,a.max_time,SUM(b.[no]) AS [no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time GROUP BY a.ID,b.min_time,a.max_time
日期比较应该加上 “=”
#7
SELECT a.ID,b.min_time,a.max_time,SUM(b.[no]) AS [no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time GROUP BY a.ID,b.min_time,a.max_time
日期比较应该加上 “=”
这是日期范围交集的用法,你没看懂
#8
SELECT a.ID,b.min_time,a.max_time,SUM(b.[no]) AS [no] FROM A INNER JOIN B ON a.ID=b.ID AND a.min_time<b.max_time AND b.min_time<a.max_time GROUP BY a.ID,b.min_time,a.max_time