Search results
23 lut 2010 · ORDER BY decode(col,'DOG',1,'CAT',2,'EEL', 3, 5) you translate DOG into value 1, CAT into value 2, EEL into value 3 and others into value 5. Then order by the resulting numeric value (ie DOG first, then CAT, then EEL, finally anything else).
4 sty 2006 · select deptno,ename. from emp. order by decode (deptno,10,'ename',20,'job',30,'hiredate')||' '||decode (deptno,10,'desc',20,'asc',30,'desc'); It should order by as follows. order by ename desc; -- if dept no is 10.
You can use expressions for the search (s), the result (r), and the default value (d) in the DECODE() function. The DECODE() function evaluates each search value (s1, s2, .., or sn) only before comparing it to the first argument (e), rather than evaluating all search values.
15 sty 2017 · The objective of this post is to explain how to perform the ordering of a table in Oracle SQL, using a list of values. We will start by creating a simple two column table and populate it. Then, we will order the table by one if its columns, by a defined list of values.
DECODE compares expr to each search value one by one. If expr is equal to a search, then Oracle Database returns the corresponding result. If no match is found, then Oracle returns default. If default is omitted, then Oracle returns null.
9 lis 2018 · Yes, if they are all numbers in the character field, you can: select * from T order by to_number(column); In fact, in Oracle8i, you could even create an index on to_number(column) and stand a chance of using that index in order to sort the data. See. </code> http://asktom.oracle.com/~tkyte/article1/index.html<code>.
29 mar 2012 · a) order by decode( l_sort_by, '12', e.name, to_char( code, '0000000000009' ) ) that is, return a character string to sort by. if sortby = 12, return ename to sort.