0
我有這個創建樞軸的MySQL的SELECT選擇。拆分複雜的mysql按日期選擇
SELECT t.*,
sum(HOUR(TIMEDIFF(STR_TO_DATE(Arbeitsbeginn, '%d.%m.%Y %H:%i:%s'),
STR_TO_DATE(Arbeitsende, '%d.%m.%Y %H:%i:%s')))) AS ARBEITSZEIT,
sum(HOUR(TIMEDIFF(STR_TO_DATE(Projektbeginn, '%d.%m.%Y %H:%i:%s'),
STR_TO_DATE(Projektende, '%d.%m.%Y %H:%i:%s')))) AS Projektzeit
FROM (SELECT DriverName,
Baustelle,
Arbeitsbeginn,
Arbeitsende,
Projektbeginn,
Projektende
FROM (SELECT DRIVERNAME,
GROUP_CONCAT(IF(ACTIONTEXT = 'PB', AREA, NULL)) AS 'Baustelle',
GROUP_CONCAT(IF(ACTIONTEXT = 'Arbeitsbeginn', DATETIME, NULL)) AS 'Arbeitsbeginn',
GROUP_CONCAT(IF(ACTIONTEXT = 'Arbeitsende', DATETIME, NULL)) AS 'Arbeitsende',
GROUP_CONCAT(IF(ACTIONTEXT = 'PB', DATETIME, NULL)) AS 'Projektbeginn',
GROUP_CONCAT(IF(ACTIONTEXT = 'PE', DATETIME, NULL)) AS 'Projektende'
FROM geoImportRoot
GROUP BY DRIVERNAME
) A CROSS JOIN
(SELECT 1 AS n UNION ALL SELECT 2) n
) t
GROUP BY DriverName;
檢查這個FIDDLE:SELECT
的問題是,我需要按日期sepereted的數據,目前,我讓他們都在一排:
2013年6月19日09 :09:01,19.06.2013 10:29:28,19.06.2013 14:01:00 11,20.06.2013 10:01:00
希望你能幫我解決這個問題。如果可能,請使用SQL小提琴
你能澄清你所說的「按日期分離」是什麼意思?我看了你的SQLFiddle輸出。你能展示你在找什麼嗎? –