Last active
December 30, 2017 15:10
-
-
Save ateneva/1260ffa13621a59cbeb9a8ccb66b33d6 to your computer and use it in GitHub Desktop.
How can I compare values with SQL?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----------------------------Vertica-------------------------------------------------------------------- | |
select | |
greatest(5.5, 8.2, -8.2) as HighestValue, -- returns the higer number, taking the sign into account | |
least(5.5, 8.2, -8.2) as LowestValue -- returns the lower number, taking the sign into account | |
-----------------------------MySQL---------------------------------------------------------------------- | |
select | |
greatest(5.5, 8.2, -8.2) as HighestValue, -- returns the higer number, taking the sign into account | |
least(5.5, 8.2, -8.2) as LowestValue -- returns the lower number, taking the sign into account | |
HighestValue |LowestValue | | |
-------------|------------| | |
8.2 |-8.2 | | |
-----------------------------PostgreSQL-------------------------------------------------------------------- | |
select | |
greatest(5.5, 8.2, -8.2) as HighestValue, -- returns the higer number, taking the sign into account | |
least(5.5, 8.2, -8.2) as LowestValue -- returns the lower number, taking the sign into account | |
highestvalue |lowestvalue | | |
-------------|------------| | |
8.2 |-8.2 | | |
----------------------------SQL Server--------------------------------------------------------------------- | |
select | |
max(MyValue) as HighestValue, -- returns the higer number, taking the sign into account | |
min(MyValue) as LowestValue -- returns the lower number, taking the sign into account | |
from (values (5.5), (8.2), (-8.2)) as a(MyValue) | |
HighestValue |LowestValue | | |
-------------|------------| | |
8.2 |-8.2 | | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment