When executing this SQL I get the error :
Column 'Buy.title' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
SQL:
IF(@sal IS NOT NULL AND @title IS NOT NULL)
BEGIN
SELECT title,type1, SUM(tedat)
FROM Buy
WHERE(@sal = YEAR(tarikh) AND @title = title)
END