2
( SELECT SUM(misyukko.dataint11) 
   FROM misyukko 
   where syouhinid='$kokyakuorderbango'
) AS total_amount

For Example:

If the sum is 12345 it will be displayed as 123,45

If the sum is 12345678 it will be displayed as 123,456,78

How to solve it?

2
  • That's not a SQL task. Fix it in the presentation. Commented Sep 17, 2020 at 9:01
  • 2
    BTW, 1234 usually is shown as 1,234. Commented Sep 17, 2020 at 9:02

1 Answer 1

3

You could use REGEXP_REPLACE here:

WITH yourTable AS (
    SELECT 12345 AS num
)

SELECT RTRIM(REGEXP_REPLACE(num::text, '(\d{3})', '\1,', 'g'), ',') AS num_out
FROM yourTable;

screen capture from demo link below

Demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.