1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
|
drop table myChecks purge;
create table myChecks (
Period date
, Language VARCHAR2(20)
, count_of NUMBER )
compress nologging;
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'Brazilian Portuguese', 8);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'Bulgarian', 1);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'Chinese', 3);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'Danish', 1);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'Dutch', 4);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'English', 85);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'Finnish', 2);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'French', 4);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'German', 51);
insert into myChecks values ( to_date(20100702,'yyyymmdd'), 'Greek', 3);
commit;
select * from myChecks;
/*
Source data easy view
PERIOD LANGUAGE COUNT_OF
--------- -------------------- ----------
02-JUL-10 Brazilian Portuguese 8
02-JUL-10 Bulgarian 1
02-JUL-10 Chinese 3
02-JUL-10 Danish 1
02-JUL-10 Dutch 4
02-JUL-10 English 85
02-JUL-10 Finnish 2
02-JUL-10 French 4
02-JUL-10 German 51
02-JUL-10 Greek 3
*/
/* Main Pivot Query */
select period , German , French , Spanish , Dutch
, Italian , Swedish , Greek , Russian , Portugese ,
Danish , SimplifiedChinese , Chinese
from myChecks
model IGNORE NAV unique single reference
return updated rows
partition by (Period )
dimension by (Language)
measures (0 count_of
, 0 Chinese , 0 Danish , 0 Dutch , 0 French
, 0 German , 0 Greek , 0 Italian
, 0 Portugese , 0 Russian , 0 SimplifiedChinese
, 0 Spanish , 0 Swedish)
rules
(
Chinese [0] = count_of [1]
, Danish [0] = count_of [2]
, Dutch [0] = count_of [3]
, French [0] = count_of [4]
, German [0] = count_of [5]
, Greek [0] = count_of [6]
, Italian [0] = count_of [7]
, Portugese [0] = count_of [8]
, Russian [0] = count_of [9]
, SimplifiedChinese [0] = count_of [10]
, Spanish [0] = count_of [11]
, Swedish [0] = count_of [12]
)
order by 1 desc;
/* Results below
PERIOD GERMAN FRENCH SPANISH DUTCH ITALIAN SWEDISH GREEK RUSSIAN PORTUGESE DANISH SIMPLIFIEDCHINESE CHINESE
--------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------------- ----------
02-JUL-10 0 0 0 0 0 0 0 0 0 0 0 0
*/
drop table myChecks purge;
|