Thanks for answering. What i mean is, with the query i have, if there are two different periods i'll get 3 columns and two rows:
AccountID SUM(Amount) PeriodName
'XXXXX' '99999999,99' AAAAA
'XXXXX' '88888888,99' BBBBB
Thank you for answering.
In fact, i found PIVOT function, which seems to suit to my needs. However, i can't put it it to work. My database version Oracle Database 11g Enterprise Edition Release 220.127.116.11.0.
I always get a "Missing keyword error..."
Yes, it is incorrect. I see two major mistakes here: missing alias in the inner query (so you cannot reference the computed column outside) and missing FOR clause.
As you did not post a test case - CREATE TABLE statements for table structure and INSERT statements for sample data - and I have no GL_BALANCE table in my Oracle database, here is equivalent query for SCOTT.EMP - converting JOBs to columns aggregated by DEPTNO:
from ( select deptno, job, nvl(sal+comm,0) some_measure from emp )
pivot ( sum(some_measure)
for job in ( 'CLERK', 'SALESMAN', 'ANALYST', 'MANAGER', 'PRESIDENT' ) );