Skip to content
Advertisement

Redshift – Breaking number into 10 parts and finding which part does a number fall into

I am trying to break down a given number into 10 equal parts and then compare a row of numbers and see in which of the 10 parts they fall under.

In the above data set, I would like to break 70 into 10 equal parts (in this case it would be 7,14,21, and so on till 70). Next I would like to see in which “part” does the value in column “number_to_check” fall into.

Output expected:

Advertisement

Answer

You want arithmetic. If I understand correctly:

Here is a db<>fiddle (the fiddle happens to use Postgres).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement