So I've gone around the houses a bit with this and not got it to work...
I have a SELECT query which contains a VARCHAR column (alloc_mth) with dates in the MMM-YY format (e.g. Jan-15) which I want to be able to ORDER BY in my query. In order to do so, I need to convert to a recognised date format. I've been following the instructions here but I'm struggling to get it to work.
My SELECT query is as follows...
SELECT `alloc_mth`, SUM(`line_cleared`), SUM(`line_count`), (SUM(`line_cleared`)/SUM(`line_count`))*100 as `Fill`
FROM `allocHist`
GROUP BY 1
ORDER BY CAST('1.' + `alloc_mth` AS DATETIME) ASC;
The end result of this is that the grouping and sum works fine but the date format and sorting doesn't...
Should this work or am I missing something?