avatar
Help on Oracle Query# Database - 数据库
b*y
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
avatar
c*t
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

avatar
b*y
3
This is for work.

【在 c**t 的大作中提到】
: home work?
avatar
c*t
4
a classical pivot query

【在 b******y 的大作中提到】
: This is for work.
avatar
B*g
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

avatar
b*y
6
Oracle 10g

【在 B*****g 的大作中提到】
: when you ask oracle questine, let us know your oracle version.
avatar
B*g
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
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。