-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathix_select_tm_gl.sql
69 lines (67 loc) · 2.55 KB
/
ix_select_tm_gl.sql
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
/* Formatted on 5/21/2012 11:44:48 AM (QP5 v5.185.11230.41888) */
SELECT /*+ FIRST_ROWS */
DISTINCT
tmb.tmcode tm,
tm.des || ' - ' || tm.shdes rate_plan,
/*tmb.spcode sp,
sp.des || ' - ' || sp.shdes service_pack,*/
DECODE (
tmb.spcode,
/*150, '50',
151, '50',
152, '50',
52, '90',*/
158, '90',
159, '90',
DECODE (
INSTR (LOWER (sp.des), 'demo'),
0, DECODE (
tmb.tmcode,
42, '20',
45, '20',
59, '20',
116, '20',
118, '20',
125, '20',
166, '20',
29, '30',
57, '40',
151, '40',
DECODE (
INSTR (LOWER (tm.des), 'internal'),
0, DECODE (
INSTR (LOWER (tm.des), 'employees'),
0, DECODE (
INSTR (LOWER (tm.des), 'corp'),
0, DECODE (
INSTR (LOWER (tm.des), 'busin'),
0, DECODE (
INSTR (LOWER (tm.des), 'buck'),
0, '10',
'20'),
'20'),
'20'),
'70'),
'70')),
'80')) || '210170'
glcode
FROM mpulktmb tmb,
rateplan tm,
mpusptab sp,
mpusntab sn
WHERE tm.tmcode = tmb.tmcode
AND sp.spcode = tmb.spcode
AND sn.sncode = tmb.sncode
AND tmb.vscode = (SELECT MAX (vscode)
FROM rateplan_version
WHERE tmcode = tmb.tmcode)
AND tmb.tmcode NOT IN
(SELECT tmcode
FROM rateplan_availability_period
WHERE available_to < TRUNC (SYSDATE) AND tmcode NOT IN (77))
AND tmb.tmcode NOT IN (14, 20, 21)
--Special Number, Pre Paid, Global Dummy Rateplan
AND tmb.tmcode NOT IN (22, 55, 56, 74)
--Roaming, CUG Rate Plan, IOT-MIG: Global Roaming, Rated CDRs
AND tmb.sncode IN (1)
ORDER BY 2, 3;