Example table: CREATE TABLE a (`id` int, `value` decimal(5,2)) ; INSERT INTO a (`id`, `value`) VALUES (1, 5), (2, 1.25), (3, 3.7), (4, 17.3) ; Goal – getting the rows in which the sum of value is 9.5 SET @counter := 0; SELECT a.*, IF(@counter
posted in sql by Ivan Gospodinow