In depth analysis of oracle specific information ranking

  • 2021-07-01 08:27:33
  • OfStack

In an Oracle query, use decode (field, 'field value ', number) of oracle if there is no sort, but you want the information of a particular value in a column to come first

For example, if you want all the data queried by select name from user, the result of name = 'Zhang 3' will be ranked first,
The following is used:
select name from user order by decode (name, 'Zhang 3', 0)
Similarly, if you want Li 4 to rank second, you can continue to add decode method
select name from user order by decode (name, 'Zhang 3', 0), decode (name, 'Li 4', 1)


Related articles: