First of all, you need to undesrtand that MAX (aggregate function) returns maximum value as a single result row based on groups of rows, rather than on single rows. Of course, you can always get single row based on single column:
SELECT MAX(ID)
FROM y
but your query returns max
id
for each
rno
.
To get expected output, try this:
SELECT MAX(ID) AS [Values]
FROM y
UNION ALL
SELECT rno AS [Values]
FROM y
but you'll never know which value belongs to which column (id or rno).
To get description of values, try this:
SELECT 'max id' AS [Description], MAX(ID) AS [Values]
FROM y
UNION ALL
SELECT 'rno' AS [Description], rno AS [Values]
FROM y
Please, refer these:
group by (functions)[
^]
aggregate functions[
^]
UNION[
^]