I have a query wit a where clause that should return records = '2014-1025' but returns all records where 2014 is in the concat so 2013-2014 and 2014-2015. I think it's the cast causing the problem

Any ideas?

Regards
Pete


Select
round(Sum(weeklytransactions.takings), 2) As Total,
Week(weeklytransactions.weekendingdate),
Cast((Case
When Month(weeklytransactions.weekendingdate) >
7 Then Concat(Year(weeklytransactions.weekendingdate), '-',
Year(weeklytransactions.weekendingdate) + 1)
Else Concat(Year(weeklytransactions.weekendingdate) - 1, '-',
Year(weeklytransactions.weekendingdate)) End) As Char) As fy
From
departments Inner Join
weeklytransactions On departments.deptid = weeklytransactions.departmentId
Inner Join
business_units On business_units.buID = departments.bus_unit
Where
Cast((Case
When Month(weeklytransactions.weekendingdate) >
5 Then Concat(Year(weeklytransactions.weekendingdate), '-',
Year(weeklytransactions.weekendingdate) + 1)
Else Concat(Year(weeklytransactions.weekendingdate) - 1, '-',
Year(weeklytransactions.weekendingdate)) End) As Char) = '2014-2015'
Group By
Week(weeklytransactions.weekendingdate), weeklytransactions.weekendingdate,
business_units.business_unit
Order By
fy Desc,
Week(weeklytransactions.weekendingdate) Desc