zerkms
Учитывая:
9.3. User Variables
...
Note: In a SELECT statement, each expression is evaluated only when sent to the client. This means that in a HAVING, GROUP BY, or ORDER BY clause, you cannot refer to an expression that involves variables that are set in the SELECT list. For example, the following statement does not work as expected
...
я все же считаю что более корректно будет вот так, тоесть с вложенным запросом:
[sql]
set @a=0, @prev:=(select shop_name from shops limit 1);
select * from (
select *, @prev, @a:=IF(@prev=shop_name, @a+1, 1) as group_counter, @prev:=shop_name from shops
) as s where group_counter<=3;
[/sql]
-~{}~ 15.12.06 13:26:
PS Запрос тестировался на MySQL 5.0.27-community-nt
-~{}~ 15.12.06 13:48:
Sad Spirit
Умеет, но на процедурах как-то стремно ...
