나는 테이블이 depart_timings
있습니다. 그것은 포함 dept_time
, station id
, bus_id
. 다른 테이블을 채우고 depart_timings_update
중복 항목을 제거 하고 싶습니다 . 새 테이블에는 min_time max_time
및 avg_time
기타 필드가 있습니다.
다음 쿼리를 사용합니다.
SELECT * , MIN(dept_time)AS mi, MAX(dept_time) as ma,SEC_TO_TIME(AVG(TIME_TO_SEC(`dept_time`))) as av FROM depart_timings GROUP BY bus_id,station_id ,HOUR(dept_time)"
모두 작동하지만 dept_time
3 시간 간격으로 그룹화해야합니다 . HOUR (dept_time)이 쿼리가 도움이되지 않았습니다. 11:55:00과 12:00:00을 별도의 그룹으로 구분합니다. 도와주세요. 내 하찮은 영어 실력에 죄송하다는 말씀을 드리고 싶습니다.
depart_timings
1 bus_id int(20)
2 dept_time time
3 station_id int(20)
4 user_id varchar(100)
5 edit_time timestamp
depart_timings_update
1 bus_id int(20)
2 station_id int(20)
3 min_time time
4 max_time time
5 avg_time time
6 edit_time timestamp
datetime을 8로 나누십시오. 이미 시간으로 변환하고 있기 때문입니다.
SELECT * , MIN(dept_time)AS mi, MAX(dept_time) as ma,SEC_TO_TIME(AVG(TIME_TO_SEC(`dept_time`))) as av FROM depart_timings GROUP BY bus_id,station_id ,HOUR(dept_time) DIV 8
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다