b******y 发帖数: 139 | 1 I have a record set like below:
CloseDate Category Price
2009-12-09 C1 100.21
2009-12-09 C2 98.41
2009-12-09 C3 96.41
2009-12-08 C1 100.13
2009-12-08 C2 98.33
2009-12-08 C3 96.33
2009-12-07 C1 100.2
2009-12-07 C2 98.25
2009-12-07 C3 96.25
2007-10-05 C4 97.4
2007-10-04 C4 97.3
2007-10-03 C4 97.3
2007-10-04 C5 98.5
2007-10-03 C5 98.4
I am trying to write a query to get columns includin | c**t 发帖数: 2744 | 2 home work?
【在 b******y 的大作中提到】 : I have a record set like below: : CloseDate Category Price : 2009-12-09 C1 100.21 : 2009-12-09 C2 98.41 : 2009-12-09 C3 96.41 : 2009-12-08 C1 100.13 : 2009-12-08 C2 98.33 : 2009-12-08 C3 96.33 : 2009-12-07 C1 100.2 : 2009-12-07 C2 98.25
| b******y 发帖数: 139 | 3 This is for work.
【在 c**t 的大作中提到】 : home work?
| c**t 发帖数: 2744 | 4 a classical pivot query
【在 b******y 的大作中提到】 : This is for work.
| B*****g 发帖数: 34098 | 5 when you ask oracle questine, let us know your oracle version.
【在 b******y 的大作中提到】 : I have a record set like below: : CloseDate Category Price : 2009-12-09 C1 100.21 : 2009-12-09 C2 98.41 : 2009-12-09 C3 96.41 : 2009-12-08 C1 100.13 : 2009-12-08 C2 98.33 : 2009-12-08 C3 96.33 : 2009-12-07 C1 100.2 : 2009-12-07 C2 98.25
| b******y 发帖数: 139 | 6 Oracle 10g
【在 B*****g 的大作中提到】 : when you ask oracle questine, let us know your oracle version.
| B*****g 发帖数: 34098 | 7 SELECT *
FROM (SELECT closedate,
MAX(DECODE(category, 'C1', price, 0)) c1,
MAX(DECODE(category, 'C2', price, 0)) c2,
MAX(DECODE(category, 'C3', price, 0)) c3,
MAX(DECODE(category, 'C4', price, 0)) c4,
MAX(DECODE(category, 'C5', price, 0)) c5
FROM tbl
GROUP BY closedate)
【在 b******y 的大作中提到】 : Oracle 10g
|
|