到目前为止,我已经得到了这个:\
SELECT Bike_Number, MaintFaultDetails, MaintactionTaken, MaintfaultDate, MaintActionDate,
COUNT(*)
FROM MaintHistory
WHERE (MaintfaultDate + 5) < MaintactionTaken
SELECT Bike_Number, MaintFaultDetails, MaintactionTaken, MaintfaultDate, MaintActionDate,
COUNT(*)
FROM MaintHistory
我会添加/编辑什么,以便计算超过5天的自行车百分比
答案 0 :(得分:0)
试试
SELECT Bike_Number, MaintFaultDetails, MaintactionTaken, MaintfaultDate, MaintActionDate,
Concat(count(Bike_Number)*100/COUNT(*).'%' ) as percent
FROM MaintHistory
WHERE DATE_ADD(MaintfaultDate, INTERVAL +5 DAY) < MaintactionTaken