特定の期間内にユーザーが欠席した合計日数を計算するにはどうすればよいですか?
これは私がどのように機能すると思うかという基本的な考え方ですが、全体を機能させることはできません。
SELECT total(from - until) FROM absences WHERE absences.user_id = 123
AND absence_date_until <= '1999-12-01' AND absence_date_from >=
'2000-12-01'
CREATE TABLE IF NOT EXISTS `absences` (
`absence_id` int(10) NOT NULL AUTO_INCREMENT,
`absence_created` datetime DEFAULT NULL,
`absence_date_from` datetime DEFAULT NULL,
`absence_date_until` datetime DEFAULT NULL,
`absence_status` enum('PENDING','APPROVED') NOT NULL,
`user_id` int(6) NOT NULL,
PRIMARY KEY (`absence_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;