MySQL限定ですが。。。
create temporary table test1(num int);
insert test1 (num) values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(2),(2),(2);
select concat(repeat(' ',9-num),repeat('#',num*2-1)) from test1;
create temporary table test1(num int);
insert test1 (num) values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(2),(2),(2);
select concat(repeat(' ',9-num),repeat('#',num*2-1)) from test1;