oracle - How to categorize several columns in one statement in SQL/PLSQL -
i've got table 20 columns categorize like; 0-25 --> 1 25-50 --> 2 50-75 --> 3 75-100 --> 4 i prefer not use 20 case ... when statements. knows how more dynamically & efficiently? can sql or pl/sql. i tried pl/sql, didn't see simple method use column names variables. many thanks. frans your example bit confusing, assuming want put value categories, function width_bucket might after: something this: with sample_data ( select trunc(dbms_random.value(1,100)) val dual connect level < 10 ) select val, width_bucket(val, 0, 100, 4) category sample_data; this assign numbers 1-4 (random) values sample_data. 0, 100 defines range build buckets, , final parameter 4 says in how many (equally wide) buckets should distributed. result of function bucket value val fall. sqlfiddle example: http://sqlfiddle.com/#!4/d41d8/10721