How is it possible to join a table with the tab_columns?
The query im trying to establish is that in my table they are 12 columns with months names. So under an input variable im trying to return the required values with the selected months. The only way i could think of to get the months to connect with the tab_columns table.
Any suggestion is really appreciated
SELECT bust,
Sum(jan) JAN,
Sum(feb) FEB,
Sum(mar) MAR,
Sum(apr) APR,
Sum(may) MAY,
Sum(jun) JUN,
Sum(jul) JUL,
Sum(aug) AUG,
Sum(sep) SEP,
Sum(oct) OCT,
Sum(nov) NOV,
Sum(DEC) DECC
FROM budget a,all_tab_columns b
WHERE vsl_code = 4602
AND code = 1
AND year=2013
AND account_code='30'
AND b.table_name='BUDGET'
AND b.column_name IN
(SELECT column_name
FROM (SELECT Column_name, ROWNUM r
FROM all_tab_columns b
WHERE table_name = 'BUDGET'
AND Column_id BETWEEN 3 AND 14
ORDER BY column_id)
WHERE r BETWEEN 2 AND 3 ) --Returns February,March
group by bust;