I have some questions regarding Max()
-
What does the following query mean?
SELECT MAX(X) -1 FROM T -
I learned that the syntax should be:
SELECT (MAX(X) -1) as max_minus_one FROM T
no? -
Do aggregation function (i.e.
Max()) must be followed byGRUOP BY?
MAX(x) - 1simply means the max value of x in the table minus one.You can always use parenthesis and aliases (
as some_cool_name) to make thing clearer, or to change names in the result. But the first syntax is perfectly valid.You only need
GROUP BYif you intend to select anything more that the aggregated value, like this for instance: