SELECT YEAR(date), COUNT(*), SUM( CASE WHEN cijena1 < cijena2 THEN 1 ELSE 0 END ) FROM table GROUP BY YEAR(date);