Oracle针对某列让特定信息排序[decode]
Jun 07, 2016 pm 05:01 PM在ORACLE查询中,如果在没有排序,但又想让某列中特定值的信息排到前面的时候,使用oracle的decode(字段,
在Oracle查询中,如果在没有排序,但又想让某列中特定值的信息排到前面的时候,使用oracle的decode(字段,'字段值',数字)
如 select name from user 查询出来的所有数据,如果想让 结果排到前面,则使用如下:
select name from user order by decode(name,'张三',0)
同理,如果想让李四排到第二的话,,可以继续增加decode方法
select name from user order by decode(name,'张三',0), decode(name,'李四',1)

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Reduce the use of MySQL memory in Docker

How do you alter a table in MySQL using the ALTER TABLE statement?

How to solve the problem of mysql cannot open shared library

Run MySQl in Linux (with/without podman container with phpmyadmin)

What is SQLite? Comprehensive overview

Running multiple MySQL versions on MacOS: A step-by-step guide

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?

How do I configure SSL/TLS encryption for MySQL connections?
