▸_sqlgym

94. Format Prices with printf

MediumString Manipulationprintf

printf builds formatted strings using C-style format codes: %.2f formats a number with two decimals, %-10s left-pads a string to width 10, and a literal $ is just written as-is.

Task: for each product return id and a label column of the form '<name padded to 10> $<price with 2 decimals>', built with printf('%-10s $%.2f', name, price). Order by id.

Output columns, in order: id, label.

Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…

This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases 5test cases in all. A sloppy query that only fits the example won't pass.

SQL
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.