Oracle SQL - 如何根据列中的值重复字符

RJP*_*RJP 10 sql string oracle

所以我试图查询得到某人的工资,然后根据他们赚取的数千来显示"$".

例如,有人赚了15,000美元,我会有另一列显示'$$$$$$$$$$$$$$$'

我可以得到这样的:

  SELECT e.last_name, 
         e.salary, 
         REPLACE(e.salary/1000, e.salary/1000, '$') AS "Graphic"
    FROM EMPLOYEES e
ORDER BY e.salary DESC, e.last_name
Run Code Online (Sandbox Code Playgroud)

但我不知道如何显示一定数量的'$'

Thi*_*ilo 24

RPAD应该工作(您可能需要稍微调整舍入):

select rpad('$', round(salary/1000), '$') as "Graphic" from employees
Run Code Online (Sandbox Code Playgroud)