如您所见,使用此代码选择一周的开始和结束。我是 sql 新手,我理解这里一般发生了什么,但我无法详细解释。例如 ;
(select lookupweekid-1 from lookupday where dateoftransaction = date) t2 (lookupweekid)
这让我很困惑。(...) t2 (...), <-我不明白最后一部分的括号在说什么
select start_of_week,end_of_week from
(select dateoftransaction
from lookupday t1,
(select lookupweekid-1 from lookupday
where dateoftransaction = date) t2 (lookupweekid)
where t1.lookupweekid=t2.lookupweekid
and t1.weekdaynumber=1) t3 (start_of_week)
,(select dateoftransaction
from lookupday t1,
(select lookupweekid-1 from lookupday
where dateoftransaction = date) t2 (lookupweekid)
where t1.lookupweekid=t2.lookupweekid
and t1.weekdaynumber=7) t4 (end_of_week)
;