Numbers to Words

This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes more than 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.


Here’s a challenging question, sent by Elad Peleg.
The following table contains a list of numbers :

 id int


Use a SQL query to convert each digit to a word


Quite simple, right 😉 ? Your solution should be applicable to any given number of rows and digits, and again – the real challenge is to solve it by using SQL only. (No variables, Procedures etc.)


Want to take the challenge to the next level ? How you would you SUM the digits of each number (using different method than what already posted) ? For example :


UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…