要求:将数据表tab1中DeviceName为‘XI003’,'DO107'的数据放在查询结果的前面,同时对其他查询结果进行降序排序
sql语句:
SELECT DISTINCT DeviceName FROM tab1 WHERE DeviceName IS NOT NULL;(不排序)
SELECT DISTINCT DeviceName FROM tab1 WHERE DeviceName IS NOT NULL ORDER BY DeviceName<>‘XI003’, DeviceName ASC;(单条数据提前展示)
SELECT DISTINCT DeviceName FROM tab1 WHERE DeviceName IS NOT NULL ORDER BY DeviceName NOT IN(‘XI003’,'DO107'), DeviceName ASC;(多条数据提前展示)