create table jobs(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
.....
salaryminus INTEGER UNSIGNED DEFAULT NULL,
salaryplus INTEGER UNSIGNED DEFAULT NULL,
.....
);
voglio fare qualcosa di simile:Come ordinare per un massimo di due colonne che possono essere nulle in MySQL?
Select * from jobs order by maxof(salaryminus, salaryplus) limit 10;
maxof(Null,1000)
dovrebbe essere 1000,
Come implementare il maxof
?
Si noti che 'GREATEST' non è SQL standard. – Charles
Non è nello standard, ma è fornito da MySQL, PostgreSQL e Oracle. È scritto "' MAX' "in SQLite. Se devi utilizzare SQL Server o devi scrivere SQL standard per una domanda sui compiti, usa "ORDINA PER CASO DOVE salaryminus> salaryplus THEN salaryminus ELSE salaryplus END" " –