|
Oracle Home |
|
Home > Oracle SQL & PL/SQL > How to add a "group by" column to a SELECT statement |
|
Oracle SQL & PL/SQL |
|---|
How to add a "group by" column to a SELECT statement |
|
Note: This article ( named How to add a "group by" column to a SELECT statement ) was taken from www.in-oracle.com.
NOTE: I named "group by" column a column based on a function like SUM, COUNT, AVG, MAX, MIN (demands a "group by" clause in the SELECT statement ).
This can be done with the over() option:
Exemples:
select max(comm) over() as max_comm, empno, ename, comm from emp;
select empno, ename, max(sal) over() as max_sal, sal from emp;
SQL> select max(comm) from emp;
SQL> select max(comm) over() as max_comm, empno,
ename, comm from emp;
You can also calculate a MAX per group:
select empno, ename, job, max(sal) over(partition by job ) as max_sal, sal from emp;
EMPNO
ENAME JOB
MAX_SAL SAL
Note: This article ( named How to add a "group by" column to a SELECT statement ) was taken from www.in-oracle.com.
|
|
Home > Oracle SQL & PL/SQL > How to add a "group by" column to a SELECT statement |
|
Different Romanian Links/ Linkuri romanesti diferite |
Disclaimer: The views expressed on this web site are my own and do not reflect the views of Oracle Corporation. You may use the information from this site only at your risk. Copyright (c) 2009-2011 Paul Catalin Tomoiu. All rights reserved.