6. Locating Numerical Value in a String

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

An advertising company manages a table that contains details about various customers, and uses this table to store their names.
At one time, When the names of the customers were imported from CSV, the customers’ names and numbers got mixed up by mistake.
In the result shown here, the first digit of each string indicates the customer number. For example: The number of the first customer is 1, the number of the second customer – 2, the number of the third customer is 4, the number of the fourth customer is 6 and so on.

CREATE TABLE customers (c_name varchar(25))    

To read more

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…