SQLTeam.com | Weblogs | Forums

How to create a new table with a column in currency format in SQL?

I'm losing my mind y'all, please don't roast me, so I have to make a new table in SQL with the columns "Name" and "totalpername". First, from the table "money" I turned the varchar into integer, summed the money up, and I used the following syntax to create a new table and make the summed up money into currency format.

INSERT INTO TotalTable AS
SELECT Name, FORMAT(SUM(REPLACE(REPLACE(Money, '

from money
GROUP BY Name;

and the error says: Error Code: 1292. Truncated incorrect INTEGER value: 'C'

What to do? Tried creating a new table first and specifying the column "totalpername" with decimal(18,2) for 2 decimal places and 18 numbers before decimal Thanks :)

without any data or ddl and the fact that your format statement is cutoff, I'll take a guess. When you sum up the Money column, it exceeds the max value of an integer column. Try casting as a bigint or decimal 9