我正在尝试提取上周首次轮班的工人名单。
现在,如果我将上周第一班的特定工作人员放在where子句(import matplotlib.pyplot as plt
import seaborn as sns
plot=sns.barplot(data=df, x=" ", y=" ")
plt.setp(plot.get_xticklabels(), rotation=90)
中,则我的SQL可用,但是当我删除该子句时,它只是超时
WHERE c.temp_nr ='XXXX'
答案 0 :(得分:0)
使用GROUP BY c.temp_nr
SELECT MIN(p.start_date), CONCAT(c.first_name, ' ', c.last_name) AS 'c.fullname', c.temp_nr
FROM contactstable c
LEFT JOIN projectlines p on c.temp_nr = p.candidate_number
WHERE c.contact_type = 'Candidate'
GROUP BY c.temp_nr
HAVING
MIN(p.start_date)
between
DATE_SUB(CURDATE(), INTERVAL (dayofweek(CURDATE())+6) DAY)
AND DATE_SUB(CURDATE() , INTERVAL (dayofweek(CURDATE())) DAY)