I have a table:
table1
record va textv numv datev
1 1 a NULL NULL
1 2 NULL 1 NULL
1 3 NULL NULL 1 jan 2015
2 1 b NULL NULL
2 2 NULL 45 NULL
3 1 c NULL NULL
3 3 NULL NULL 5 feb 2015
I need to convert to:
va1 va2 va3
a 1 1 jan 2015
b 45 NULL
c NULL 5 Feb 2015
How can I do this in Oracle 11g?
you may use below query:
WITH Q1 as
(select record, max (textv) over (partition by record order by va) va1
,max (numv) over (partition by record order by va) va2
max (datev) over (partition by record order by va) va3
)
select distinct record,va1,va2,va3 from Q1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.