If you are using Oracle 10g or later, you can use analytic functions like rank, mix and max.
1 select ename, sal, deptno
2 , decode(min(sal)over(partition by deptno), sal, 'MIN')
3 , decode(max(sal)over(partition by deptno), sal, 'MAX')
4* from emp
ENAME SAL DEPTNO DEC DEC
---------- ---------- ---------- --- ---
CLARK 2450 10
KING 5000 10 MAX
MILLER 1300 10 MIN
JONES 2975 20
FORD 3000 20 MAX
ADAMS 1100 20
SMITH 800 20 MIN
SCOTT 3000 20 MAX
WARD 1250 30
TURNER 1500 30
ALLEN 1600 30
JAMES 950 30 MIN
BLAKE 2850 30 MAX
MARTIN 1250 30
14 rows selected.
I am aware of the use of case. I was already using it I just dumbed down the example to attempt to prevent simplistic answers like the last one. FAIL!
Anyway, I solved my problem by using a temporary table so that sybase wasn't confused by the table aliases which was at the root of the initial problem.