Skip to Main Content

rows to columns

RaunaqFeb 12 2015 — edited Feb 13 2015

hi ,

i am on 11g

I have a query which returns data inthe following format ,

YEAR COUNT

2015 445

2015 115

2015 577

2015 11

2015 28

2015 30

2015 270

2015 87

2015 62

2015 68

2015 15

2015 10

2015 5

2015 12

2015 34

2015 118

2015 19

2014 1541

2014 25

2014 581

2014 22

2014 18

2014 59

2014 7828

2014 7

2014 4

Now i want all the data to be displayed in one row for each year

Example:

col1   col2 col3 col4......

2015 445 115 577......

2014 25 581...

2013....

.

.

.

.

and so on ....

i am getting the above data by running the following query:

{code}

select to_char(create_dt,'YYYY') "YEAR",

COUNT(*) Count

FROM SCH1.Tab1 , table2

Where tab1.c1=table2.c1

group by

to_char(create_dt,'YYYY') ,

tab1.col1

Comments
Post Details
Added on Feb 12 2015
6 comments
127 views