I have a table like this:

and what I need is a sum of amounts in given year for given department.
I tried this:
SELECT SUM(amount) FROM `spendings` WHERE dept_name='fiz' AND YEAR(date)=2012
but it only returns NULL. dept_name is a varchar, amount is a double and date – well, it’s a date, what a surprise.
What am I doing wrong?
You don’t have any records
WHERE dept_name='fiz' AND YEAR(date)=2012. The two records for dept'fiz'are for'2010'and'2011'.