runtime
66 / 88

task Validation & types · hard

Parse money into exact integer cents

For every import row, parse raw_amount into cents or NULL and label status valid or invalid. Trim outer ASCII spaces. Accept an optional leading + or -, one to six ASCII whole-number digits, and optionally a decimal point followed by one or two ASCII digits.

what to return

Columns
import_idcentsstatus in this order
Rows
19 rows · in the order asked
Watch for
Leading zeros count toward the six-digit limit. Signed zero is valid. Missing whole digits, a trailing dot, exponents, separators, currency symbols and NULL are invalid.
Use integer cents: 19.99 is 1999 and -0.29 is -29. No floating-point tolerance is intended. Return every row ordered by import_id.
Skill
Turn validated decimal text into exact integer minor units. Refresher: CAST, text types & NULL arithmetic →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result19 rows · in this order
import_idcentsstatus
11999valid
229valid
3-1250valid

first 3 of 19 rows

data you can query

Sample rows from each table. Each column shows its type underneath; → marks a link to another table.

market_raw_import4 columns · 19 rows
idinteger · keyraw_codetextraw_emailtextraw_amounttext
1 hm-0042-us Ana@Harbor.test 19.99
2HM-0007-GBana@harbor.test0.29
3HM-12x4-US Ben@harbor.test -12.50
4HM-12345-US BEN@HARBOR.TEST +12
5HM-123-USa@@harbor.test12x

showing 5 of 19 rows

solution.sql
 

Hints and the answer are always available. Using them counts the question as solved with help.