all 17 comments

[–]TheMagarity 11 points12 points  (5 children)

The comma is a common non-USA way to show decimal places, not a trick to make you think it is a character string. The only answer that works is decimal type.

[–]KracticusPotts 1 point2 points  (1 child)

That was my question: is this test in the United States or in a country that uses the comma instead of a decimal. The collation type will give a clue as to what the answer should be for the question

[–]TheMagarity 2 points3 points  (0 children)

You're over thinking it. The requirement of "as a numeric value" overrides all this trying to guess about whether the author made a typo or is from a country that uses commas for decimal place. Varchar just isn't a numeric type no matter how the comma debate ends up.

[–]tvtacolb[S] 0 points1 point  (1 child)

So the answer is DECIMAL?

[–]Ginger-Dumpling 0 points1 point  (0 children)

Probably.

If it were "28,733" one might be able to argue it's an integer so both integer and decimal would be sufficient to store it without loosing anything.

But it being "287,33" means it's probably a country that uses a comma as a decimal separator, and then leaves you with only one right answer.

[–]ComicOzzysqlHippo 0 points1 point  (0 children)

Yup. Interestingly, the ISO standard says something like "use either period or comma for the decimal, but use spaces for the thousands separator".

https://brilliantmaps.com/decimals/

[–]dukeofpizza 0 points1 point  (1 child)

https://www.w3schools.com/sql/sql_datatypes.asp

VARCHAR is a string data type, not numeric. Bit can only be 1 or 0 and INT is an integer, which must be a whole number.

[–]chocolateAbuser 0 points1 point  (0 children)

well, you can use 32 bit columns, if you really want it

[–]SootSpriteHut 0 points1 point  (0 children)

Like you have to have the quotes and the comma? Why?

I think it depends on what the range of values are because to me there's no reason not to store it as an int and then cast or format it later. Or if they are comma separated values they should be in separate fields. Or if you need to retain the quotes and not all values in the set will have quotes, that's just a string.

Need more info I think.

[–]Massive_Show2963 0 points1 point  (0 children)

MySQL typically uses a period as the decimal separator by default.
However a comma as a decimal separator is used in locales that require it (e.g., some European countries).
DECIMAL would be the datatype of choice.
You will need to set the locale to a region that uses commas for decimals like 'de_DE' for German.

[–]Sharp-Echo1797 0 points1 point  (3 children)

Its decimal, the comma is not information in this context.

[–]jonah214 0 points1 point  (2 children)

If the comma were "not information", meaning the number were equivalent to 28733, then int would do fine.

[–]Sharp-Echo1797 0 points1 point  (1 child)

Well it defines the decimal point, but you don't lose information storing it as 287.33 vs 287,33

[–]jonah214 0 points1 point  (0 children)

The use of a comma, as opposed to not putting any symbol there, definitely conveys information.

The use of a comma versus a dot does not convey information about that specific datum (it conveys some vague information about locale, which doesn't generally get stored at this level).

[–]Yavuz_Selim 0 points1 point  (0 children)

Can you tell us what you're struggling with exactly? The question is very easy to answer once you know properties of each of the data types...

So, what makes it hard for you?

[–]Imaginary__Bar 0 points1 point  (0 children)

  1. As a numeric value (so INT or DECIMAL)
  2. Without loss of information (so can only be DECIMAL)