Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SUM did not return the correct DecimalSize() #1671

Unanswered
didip asked this question in Q&A
Discussion options

Example SQL:

select sum(1 + 2) as col

Called this function to get precision and scale:

precision, scale, ok := columnType.DecimalSize()

The returned precision is 42. I don't understand where did 42 come from. It's supposed to be 1, right?

You must be logged in to vote

Replies: 1 comment

Comment options

It returns precision and scale of column type, not a value in specific row.
In this case, it represents max digits in the DECIMAL type that SUM returns. (I don't know what database and version you are using.)

See also: https://pkg.go.dev/database/sql/driver#RowsColumnTypePrecisionScale

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1670 on January 29, 2025 04:08.

AltStyle によって変換されたページ (->オリジナル) /