Ok first i have immutable values :
4 8 16 32 64 128 256
and i have one table something like that :
+----+------
The following procedure will return 4 columns. The first and second columns should be displayed. The third column is just the rownum which should be ignored. If the fourth column is not blank then display it in the next row otherwise don't display it.
DELIMITER //
create procedure test()
BEGIN
declare N int;
declare X int;
select count(*) from players where y_of_birth=2000 into N;
set X = power(2,ceil(log2(N))) -N;
SELECT full_name, club_name, @row := @row + 1 AS row,
case when (@row<= X)
then 'any word' else '' end r
FROM players, (SELECT @row:=0) z
where y_of_birth=2000;
END //
DELIMITER
call test;