문제

I have a table that has a set of integers: i.e. 1, 2, 4, 50, 399, 600, 1245 etc. I need to rank these numbers but with 50 increment as the range. So the number will be truncated to the 0, 50, 100, 150, 200, 250, etc. The outcome will look like this:

col1 [10, 883, 709, 11, 425, 945, 825, 1000, 471, 79, 753]

col2 [0, 850, 700, 0, 400, 900, 800, 1000, 450, 50, 750]

I started with the code below but cannot get to the 50 breaks. Anyone can help? :(

select page_count, truncate(page_count, -1.5)
from a_bkinfo.books
도움이 되었습니까?

해결책

select page_count, truncate(page_count / 50, 0) * 50 as rounded_page_count
from a_bkinfo.books
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top