教练表:
巡回表:
创建一个查询,显示给定日期的可用教练列表
我坚持这个查询,我不知道如何继续:
SELECT
c.coachID,
c.coachNo
FROM
Tour t
inner join Coach c
on t.coachID=c.coachID
WHERE
'10/01/2016' BETWEEN startDate AND (DATEADD(DAY,tourDuration,startDate))
输出:
coachID|coachNo
1 |WKS5623
答案 0 :(得分:1)
我们可以通过以下方式获得可用的教练
找出现在正在巡回演出的教练
SELECT
DISTINCT CoachID
FROM Tour
WHERE '10/01/2016' BETWEEN startDate AND (DATEADD(DAY, tourDuration, startDate))
让那些不在教练名单中的教练现在参加巡回赛
SELECT
CoachId, CoachNo
FROM Coach
WHERE CoachId NOT IN
(
SELECT
DISTINCT CoachID
FROM Tour
WHERE '10/01/2016' BETWEEN startDate AND (DATEADD(DAY, tourDuration, startDate))
)
希望它可以帮助你。