[英]Replace numbers by symbols SQL
I'm currently struggling.. I'm trying to convert values (Salarys) to * (stars) That means for 3000 it should give me *** as Result.我目前正在挣扎..我正在尝试将值(Salarys)转换为 *(stars)这意味着对于 3000,它应该给我 *** 作为结果。 Per 1000 should one * be made.
每 1000 应该做一个 *。 Can anyone help me out?
谁能帮我吗?
Edit: My current solution (not working)编辑:我目前的解决方案(不工作)
SELECT SUBSTR(LAST_NAME, 0,8) as h, round(SALARY, -3) FROM EMPLOYEES
So I already rounded on 1000, but how do I change it to Stars??所以我已经四舍五入了 1000,但是如何将其更改为 Stars?
Try something like尝试类似的东西
SELECT REPEAT('*', FLOOR(Salary / 1000));
Simply divide your salary with 1000, then round so you have no decimals and then you repeat * x-times.只需将你的工资除以 1000,然后四舍五入,这样你就没有小数,然后你重复 * x 次。
EDIT (depending on the comment):编辑(取决于评论):
SELECT SUBSTR(LAST_NAME, 0, 8) AS h, REPEAT('*', FLOOR(Salary / 1000))
FROM EMPLOYEES
WHERE SALARY <> 0;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.