我的理解是GREATEST()和LEAST()不是SQL标准的一部分,但是很常见。SQL标准中最高和最低标准
我在想,有没有办法克隆GREATEST的功能保持在SQL标准内?
SELECT id, GREATEST(1,2,3,4,5,6,7) AS number FROM table
完全查询:
SELECT SUBSTR(section,1,2) AS campus,
AVG(GREATEST(maximum - enrolled, 0)) AS empty
FROM sectionrun
WHERE coursenumber = '105' AND subject = 'ENGL'
GROUP BY campus
什么数据库? GREATEST&LEAST由[PostgreSQL](http://www.postgresql.org/docs/8.1/interactive/functions-conditional.html),[MySQL](http://dev.mysql.com/doc/refman /4.1/en/comparison-operators.html#function_greatest),[Oracle](http://techonthenet.com/oracle/functions/greatest.php)。 SQL Server是唯一不支持GREATEST/LEAST的专业。 – 2010-09-25 17:58:40
我知道PostgreSQL和MySQL支持GREATEST/LEAST。我的问题涉及实际的SQL标准http://en.wikipedia.org/wiki/SQL#Standardization – WalterJ89 2010-09-25 22:35:51
另请参阅:http://stackoverflow.com/questions/71022/sql-max-of-multiple-columns – 2012-05-23 12:07:02