Transposition of data, SQL enigma
Date: 1996/10/08
Message-ID: <53eb8i$3jl_at_ralph.vnet.net>#1/1
I have a table laid out in the following (simplified) fashion:
SQL> desc monthly
Name Null? Type
------------------------------- -------- ----
ACCTNUM NOT NULL NUMBER
LSEQ NUMBER
YR_MO NOT NULL VARCHAR2(4)
ABAL NUMBER
ACCD NUMBER
ACCN NUMBER
[...]
Where ABAL, ACCD, ACCN are all for a particular YR_MO (Year, Month). I need to make a result-set look like the following:
ACCTNUM ABAL9505 ABAL9506 ABAL9507 ABAL9508 ABAL9509 ABAL9510 ABAL9511 ... So simply the SQL would have aliases on the selected data columns to rename them, like:
SELECT ACCTNUM, ABAL as ABAL9505, ACCD as ACCD9505, ACCN as ACCN9505, ...
FROM MONTHLY
WHERE YR_MO = '9505';
However, how do I tag the next query on to get the columns ABAL9506, etc.
If you know, a quick note to aje_at_vnet.net would be extremely appreciated! I'm working at First Union National Bank right now and could really use some help.
-- Andrew Joseph Esposito aje_at_vnet.net http://www.vnet.net/users/ajeReceived on Tue Oct 08 1996 - 00:00:00 CEST