clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2805464 fiddles created (40823 in the last week).

CREATE TABLE docs (name VARCHAR(255), salary INT);
 hidden batch(es)


INSERT INTO docs VALUES (NULL, 1), ('name-1', NULL), ('name-1', 5), ('name-1', 4), ('name-2', 2), (null,null), ('name-3', 3), ('name-4', 4);
 hidden batch(es)


SELECT name, salary FROM docs ORDER BY name IS NULL ASC, -- name IS NULL - в самый конец name, -- затем сортировать по name salary IS NOT NULL DESC, -- для равных же name salary IS NULL в конец salary -- а остальные по возрастанию
name salary
name-1 4
name-1 5
name-1
name-2 2
name-3 3
name-4 4
1
 hidden batch(es)