我有以下MySQL查詢:MySQL查詢MS SQL
SELECT date, time, custom_id, Number
FROM traffic t
WHERE CONCAT(date, " ", time) BETWEEN "01/06/2014 00:00" AND "01/10/2014 23:00"
AND Number =
(SELECT MAX(CAST(Number as SIGNED)) FROM traffic WHERE t.date = date and t.custom_id = custom_id)
ORDER BY date, CAST(Number as SIGNED) DESC, custom_id
這是SQLFiddle在MySQL(工作):http://sqlfiddle.com/#!2/6e1248/3
我怎麼能轉換/翻譯成MS SQL? SQLFiddle(不工作):提前http://sqlfiddle.com/#!6/6e124/1
感謝
爲什麼日期和時間分隔列?除非日期格式適合DATE,否則這在MySQL中也不起作用! – Strawberry
由於日期時間格式,查詢可能在MySQL中不起作用。跨越月份邊界時,「between」不起作用。 –
http://sqlfiddle.com/#!6/6e124/21 – Mihai