Query with flag
Hi,
I've this table:
CREATE TABLE T_DAY
DAY NUMBER,
BL_ID VARCHAR2(64),
C_MONTH VARCHAR2(64),
WR_ID INTEGER,
PMP_GROUP VARCHAR2(64)
ALTER TABLE T_DAY ADD (
CONSTRAINT T_DAY_PK
PRIMARY KEY
(WR_ID)
with these data:
DAY........BL_ID.........C_MONTH.........WR_ID.........PMP_GROUP
1..........BL-001.........2009-3.........10............GROUP_1
11.........BL-001.........2009-3.........11............GROUP_1
13.........BL-001.........2009-3.........15............GROUP_1
15.........BL-001.........2009-3.........16............GROUP_1
18.........BL-001.........2009-3.........19............GROUP_1
19.........BL-001.........2009-3.........190...........GROUP_1
1..........BL-007.........2009-2.........112............GROUP_2
22.........BL-007.........2009-2.........113............GROUP_2
4..........BL-008.........2009-4.........140............GROUP_5
5..........BL-008.........2009-4.........141............GROUP_5
6..........BL-008.........2009-4.........145............GROUP_5
7..........BL-008.........2009-4.........146............GROUP_5
28..........BL-012........2009-5.........170............GROUP_6
20..........BL-015........2008-9.........111............GROUP_8
21..........BL-015........2008-9.........116............GROUP_8
23..........BL-015........2008-9.........156............GROUP_8
25..........BL-015........2008-9.........166............GROUP_8
.............................................................. more 1000 rows
I'd like to get for each BL_ID and C_MONTH, 31 rows (1,2,3............31) with a flag on PMP_GROUP's values.
For example: GROUP_1 has WR_ID for days: 1,11,13,15,18,19
I'd like to get a query with this output:
DAY........BL_ID.........C_MONTH......GROUP_1....GROUP_2...GROUP_5...GROUP_6...GROUP_8
1.........BL-001.........2009-3.................X........................................................................................
2.........BL-001.........2009-3..........................................................................................................
3.........BL-001.........2009-3..........................................................................................................
4.........BL-001.........2009-3..........................................................................................................
5.........BL-001.........2009-3..........................................................................................................
6.........BL-001.........2009-3..........................................................................................................
7.........BL-001.........2009-3..........................................................................................................
8.........BL-001.........2009-3..........................................................................................................
9.........BL-001.........2009-3..........................................................................................................
10.........BL-001.........2009-3..........................................................................................................
11.........BL-001.........2009-3..................X........................................................................................
12.........BL-001.........2009-3..........................................................................................................
13.........BL-001.........2009-3..................X..........................................................................................
14.........BL-001.........2009-3.........................................................................................................
15.........BL-001.........2009-3..................X....................................................................................
16.........BL-001.........2009-3..........................................................................................................
17.........BL-001.........2009-3..........................................................................................................
18.........BL-001.........2009-3..................X........................................................................................
19.........BL-001.........2009-3..................X..........................................................................................
20.........BL-001.........2009-3.......................................................................................................
21.........BL-001.........2009-3.......................................................................................................
22.........BL-001.........2009-3.......................................................................................................
23.........BL-001.........2009-3.......................................................................................................
24.........BL-001.........2009-3.......................................................................................................
25.........BL-001.........2009-3.......................................................................................................
26.........BL-001.........2009-3.......................................................................................................
27.........BL-001.........2009-3.......................................................................................................
28.........BL-001.........2009-3.......................................................................................................
29.........BL-001.........2009-3.......................................................................................................
30.........BL-001.........2009-3.......................................................................................................
31.........BL-001.........2009-3.......................................................................................................
1.........BL-007.........2009-2.................................................X..........................................................
2.........BL-007.........2009-2.............................................................................................................
22.........BL-007.........2009-2...............................................X..........................................................
31.........BL-007.........2009-2...............................................................................................................
1.........BL-008.........2009-4...........................................................X...................................................
2.........BL-008.........2009-4...........................................................X...................................................
3.........BL-008.........2009-4...........................................................X...................................................
4.........BL-008.........2009-4...........................................................X...................................................
5.........BL-008.........2009-4...........................................................X...................................................
6.........BL-008.........2009-4...........................................................X...................................................
7.........BL-008.........2009-4...........................................................X...................................................
31.........BL-008.........2009-4...............................................................................................................
1.........BL-012.........2009-5...............................................................................................................
28.........BL-012.........2009-5.......................................................................X....................................
31.........BL-012.........2009-5...............................................................................................................
1.........BL-015.........2008-9...............................................................................................................
20.........BL-015.........2008-9............................................................................................................X
21.........BL-015.........2008-9............................................................................................................X
23.........BL-015.........2008-9............................................................................................................X
25.........BL-015.........2008-9............................................................................................................X
31.........BL-015.........2008-9...............................................................................................................
How Can I write a query to get this output?
Thanks in advance!
Sorry, forgot to remove that outer join
SQL> ed
Wrote file afiedt.buf
1 SELECT day,
2 bl_id,
3 c_month,
4 max( decode( pmp_group, 'GROUP_1', 'X', null ) ) group_1,
5 max( decode( pmp_group, 'GROUP_2', 'X', null ) ) group_2,
6 max( decode( pmp_group, 'GROUP_5', 'X', null ) ) group_5,
7 max( decode( pmp_group, 'GROUP_6', 'X', null ) ) group_6,
8 max( decode( pmp_group, 'GROUP_8', 'X', null ) ) group_8
9 FROM (
10 SELECT day, bl_id, c_month, pmp_group
11 FROM t_day
12 UNION ALL
13 SELECT a.lvl, b.bl_id, b.c_month, null pmp_group
14 FROM (SELECT level lvl FROM dual CONNECT BY level <= 31) a,
15 (SELECT distinct bl_id, c_month FROM t_day) b
16 WHERE NOT EXISTS(
17 SELECT 1
18 FROM t_day c
19 WHERE c.day = a.lvl
20 AND c.bl_id = b.bl_id
21 AND c.c_month = b.c_month)
22 )
23 group by day, bl_id, c_month
24* order by bl_id, c_month, day
SQL> /
DAY BL_ID C_MONTH G G G G G
1 BL-001 2009-3 X
2 BL-001 2009-3
3 BL-001 2009-3
4 BL-001 2009-3
5 BL-001 2009-3
6 BL-001 2009-3
7 BL-001 2009-3
8 BL-001 2009-3
9 BL-001 2009-3
10 BL-001 2009-3
11 BL-001 2009-3 X
12 BL-001 2009-3
13 BL-001 2009-3 X
14 BL-001 2009-3
15 BL-001 2009-3 X
16 BL-001 2009-3
17 BL-001 2009-3
18 BL-001 2009-3 X
19 BL-001 2009-3 X
20 BL-001 2009-3
21 BL-001 2009-3
22 BL-001 2009-3
23 BL-001 2009-3
24 BL-001 2009-3
25 BL-001 2009-3
26 BL-001 2009-3
27 BL-001 2009-3
28 BL-001 2009-3
29 BL-001 2009-3
30 BL-001 2009-3
31 BL-001 2009-3
1 BL-007 2009-2 X
2 BL-007 2009-2
3 BL-007 2009-2
4 BL-007 2009-2
5 BL-007 2009-2
6 BL-007 2009-2
7 BL-007 2009-2
8 BL-007 2009-2
9 BL-007 2009-2
10 BL-007 2009-2
11 BL-007 2009-2
12 BL-007 2009-2
13 BL-007 2009-2
14 BL-007 2009-2
15 BL-007 2009-2
16 BL-007 2009-2
17 BL-007 2009-2
18 BL-007 2009-2
19 BL-007 2009-2
20 BL-007 2009-2
21 BL-007 2009-2
22 BL-007 2009-2 X
23 BL-007 2009-2
24 BL-007 2009-2
25 BL-007 2009-2
26 BL-007 2009-2
27 BL-007 2009-2
28 BL-007 2009-2
29 BL-007 2009-2
30 BL-007 2009-2
31 BL-007 2009-2
1 BL-008 2009-8
2 BL-008 2009-8
3 BL-008 2009-8
4 BL-008 2009-8 X
5 BL-008 2009-8 X
6 BL-008 2009-8 X
7 BL-008 2009-8 X
8 BL-008 2009-8
9 BL-008 2009-8
10 BL-008 2009-8
11 BL-008 2009-8
12 BL-008 2009-8
13 BL-008 2009-8
14 BL-008 2009-8
15 BL-008 2009-8
16 BL-008 2009-8
17 BL-008 2009-8
18 BL-008 2009-8
19 BL-008 2009-8
20 BL-008 2009-8
21 BL-008 2009-8
22 BL-008 2009-8
23 BL-008 2009-8
24 BL-008 2009-8
25 BL-008 2009-8
26 BL-008 2009-8
27 BL-008 2009-8
28 BL-008 2009-8
29 BL-008 2009-8
30 BL-008 2009-8
31 BL-008 2009-8
1 BL-012 2009-5
2 BL-012 2009-5
3 BL-012 2009-5
4 BL-012 2009-5
5 BL-012 2009-5
6 BL-012 2009-5
7 BL-012 2009-5
8 BL-012 2009-5
9 BL-012 2009-5
10 BL-012 2009-5
11 BL-012 2009-5
12 BL-012 2009-5
13 BL-012 2009-5
14 BL-012 2009-5
15 BL-012 2009-5
16 BL-012 2009-5
17 BL-012 2009-5
18 BL-012 2009-5
19 BL-012 2009-5
20 BL-012 2009-5
21 BL-012 2009-5
22 BL-012 2009-5
23 BL-012 2009-5
24 BL-012 2009-5
25 BL-012 2009-5
26 BL-012 2009-5
27 BL-012 2009-5
28 BL-012 2009-5 X
29 BL-012 2009-5
30 BL-012 2009-5
31 BL-012 2009-5
1 BL-015 2008-9
2 BL-015 2008-9
3 BL-015 2008-9
4 BL-015 2008-9
5 BL-015 2008-9
6 BL-015 2008-9
7 BL-015 2008-9
8 BL-015 2008-9
9 BL-015 2008-9
10 BL-015 2008-9
11 BL-015 2008-9
12 BL-015 2008-9
13 BL-015 2008-9
14 BL-015 2008-9
15 BL-015 2008-9
16 BL-015 2008-9
17 BL-015 2008-9
18 BL-015 2008-9
19 BL-015 2008-9
20 BL-015 2008-9 X
21 BL-015 2008-9 X
22 BL-015 2008-9
23 BL-015 2008-9 X
24 BL-015 2008-9
25 BL-015 2008-9 X
26 BL-015 2008-9
27 BL-015 2008-9
28 BL-015 2008-9
29 BL-015 2008-9
30 BL-015 2008-9
31 BL-015 2008-9
155 rows selected.and as I mentioned, the WHERE EXISTS can be eliminated if you're just doing the pivot
SQL> ed
Wrote file afiedt.buf
1 SELECT day,
2 bl_id,
3 c_month,
4 max( decode( pmp_group, 'GROUP_1', 'X', null ) ) group_1,
5 max( decode( pmp_group, 'GROUP_2', 'X', null ) ) group_2,
6 max( decode( pmp_group, 'GROUP_5', 'X', null ) ) group_5,
7 max( decode( pmp_group, 'GROUP_6', 'X', null ) ) group_6,
8 max( decode( pmp_group, 'GROUP_8', 'X', null ) ) group_8
9 FROM (
10 SELECT day, bl_id, c_month, pmp_group
11 FROM t_day
12 UNION ALL
13 SELECT a.lvl, b.bl_id, b.c_month, null pmp_group
14 FROM (SELECT level lvl FROM dual CONNECT BY level <= 31) a,
15 (SELECT distinct bl_id, c_month FROM t_day) b
16 )
17 group by day, bl_id, c_month
18* order by bl_id, c_month, day
SQL> /
DAY BL_ID C_MONTH G G G G G
1 BL-001 2009-3 X
2 BL-001 2009-3
3 BL-001 2009-3
4 BL-001 2009-3
5 BL-001 2009-3
6 BL-001 2009-3
7 BL-001 2009-3
8 BL-001 2009-3
9 BL-001 2009-3
10 BL-001 2009-3
11 BL-001 2009-3 X
12 BL-001 2009-3
13 BL-001 2009-3 X
14 BL-001 2009-3
15 BL-001 2009-3 X
16 BL-001 2009-3
17 BL-001 2009-3
18 BL-001 2009-3 X
19 BL-001 2009-3 X
20 BL-001 2009-3
21 BL-001 2009-3
22 BL-001 2009-3
23 BL-001 2009-3
24 BL-001 2009-3
25 BL-001 2009-3
26 BL-001 2009-3
27 BL-001 2009-3
28 BL-001 2009-3
29 BL-001 2009-3
30 BL-001 2009-3
31 BL-001 2009-3
1 BL-007 2009-2 X
2 BL-007 2009-2
3 BL-007 2009-2
4 BL-007 2009-2
5 BL-007 2009-2
6 BL-007 2009-2
7 BL-007 2009-2
8 BL-007 2009-2
9 BL-007 2009-2
10 BL-007 2009-2
11 BL-007 2009-2
12 BL-007 2009-2
13 BL-007 2009-2
14 BL-007 2009-2
15 BL-007 2009-2
16 BL-007 2009-2
17 BL-007 2009-2
18 BL-007 2009-2
19 BL-007 2009-2
20 BL-007 2009-2
21 BL-007 2009-2
22 BL-007 2009-2 X
23 BL-007 2009-2
24 BL-007 2009-2
25 BL-007 2009-2
26 BL-007 2009-2
27 BL-007 2009-2
28 BL-007 2009-2
29 BL-007 2009-2
30 BL-007 2009-2
31 BL-007 2009-2
1 BL-008 2009-8
2 BL-008 2009-8
3 BL-008 2009-8
4 BL-008 2009-8 X
5 BL-008 2009-8 X
6 BL-008 2009-8 X
7 BL-008 2009-8 X
8 BL-008 2009-8
9 BL-008 2009-8
10 BL-008 2009-8
11 BL-008 2009-8
12 BL-008 2009-8
13 BL-008 2009-8
14 BL-008 2009-8
15 BL-008 2009-8
16 BL-008 2009-8
17 BL-008 2009-8
18 BL-008 2009-8
19 BL-008 2009-8
20 BL-008 2009-8
21 BL-008 2009-8
22 BL-008 2009-8
23 BL-008 2009-8
24 BL-008 2009-8
25 BL-008 2009-8
26 BL-008 2009-8
27 BL-008 2009-8
28 BL-008 2009-8
29 BL-008 2009-8
30 BL-008 2009-8
31 BL-008 2009-8
1 BL-012 2009-5
2 BL-012 2009-5
3 BL-012 2009-5
4 BL-012 2009-5
5 BL-012 2009-5
6 BL-012 2009-5
7 BL-012 2009-5
8 BL-012 2009-5
9 BL-012 2009-5
10 BL-012 2009-5
11 BL-012 2009-5
12 BL-012 2009-5
13 BL-012 2009-5
14 BL-012 2009-5
15 BL-012 2009-5
16 BL-012 2009-5
17 BL-012 2009-5
18 BL-012 2009-5
19 BL-012 2009-5
20 BL-012 2009-5
21 BL-012 2009-5
22 BL-012 2009-5
23 BL-012 2009-5
24 BL-012 2009-5
25 BL-012 2009-5
26 BL-012 2009-5
27 BL-012 2009-5
28 BL-012 2009-5 X
29 BL-012 2009-5
30 BL-012 2009-5
31 BL-012 2009-5
1 BL-015 2008-9
2 BL-015 2008-9
3 BL-015 2008-9
4 BL-015 2008-9
5 BL-015 2008-9
6 BL-015 2008-9
7 BL-015 2008-9
8 BL-015 2008-9
9 BL-015 2008-9
10 BL-015 2008-9
11 BL-015 2008-9
12 BL-015 2008-9
13 BL-015 2008-9
14 BL-015 2008-9
15 BL-015 2008-9
16 BL-015 2008-9
17 BL-015 2008-9
18 BL-015 2008-9
19 BL-015 2008-9
20 BL-015 2008-9 X
21 BL-015 2008-9 X
22 BL-015 2008-9
23 BL-015 2008-9 X
24 BL-015 2008-9
25 BL-015 2008-9 X
26 BL-015 2008-9
27 BL-015 2008-9
28 BL-015 2008-9
29 BL-015 2008-9
30 BL-015 2008-9
31 BL-015 2008-9
155 rows selected.Justin
Similar Messages
-
Oracle hangs on query with multiple joins
To test the sotftware from the LMS-vendor that are out partners we use virtual machines where we install Windows 2003 servers and Oracle XE
While we were testing the software I've found that a particular query with multiple unions causes the CPU of the virtual machine totally claimed by oracle
The query causes oracle to hang.
I've found that the subcomponents of the query all return 0 rows (and response all immediately) combined into a query with at least 2 unions the query hangs the system
I'm not familiar with with Database Management at all
I've read something about SGA and PGA that could be the issue and tried to increase the target for both but it doesn't seem to do anything
Some characterics
Target Current
Maximum System Global Area (SGA) Size: 380 MB 380 MB
Program Global Area (PGA) Aggregate Target: 360 MB 38 MB
Current Configuration: (SGA + PGA): 740 MB 418 MB
Tablespaces Percent Used Allocated (MB) Used (MB) Datafiles
SYSAUX 98.21% 460.00 451.75 1
SYSTEM 73.09% 510.00 372.75 1
DATA 99.13% 440.00 436.19 1
UNDO 6.48% 160.00 10.38 1
USERS 1.63% 100.00 1.63 1
sort_area_size 65536
shared_pool_reserved_size 5452595 TRUE size in bytes of reserved area of shared pool
shared_pool_size 0 TRUE size in bytes of shared pool
What other parameters are important? How could I get a good picture to see what's really going on?
Some pointers, help would be appreciated.
Regards,
RemcoBelow is the base-query that is causing the problems
SELECT /* Public - Internal learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no order_number, e.id person_id, format_name(e.fname , e.lname , @@005) learner_name , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description item_desc, substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1 , r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN tpt_oe_order_items i ON i.reg_id = r.id INNER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id INNER JOIN tpt_company c ON e.company_id = c.id INNER JOIN tpt_offering_action oa on r.offering_action_id = oa.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name INNER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name INNER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name INNER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name WHERE e.type = 100 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003))
UNION
SELECT /* Public - External learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , e.id person_id, format_name(e.fname , e.lname , @@005) , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1, r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN tpt_oe_order_items i ON i.reg_id = r.id INNER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id INNER JOIN tpt_offering_action oa on r.offering_action_id = oa.id LEFT OUTER JOIN tpt_company c ON e.company_id = c.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name INNER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name INNER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name INNER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name WHERE e.type = 200 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003))
UNION
SELECT /* Public - Unassigned learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , null person_id, null , null company_id, null , ent.id entidd, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1, r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,'' org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,'' learner_first_name ,'' learner_last_name FROM tpt_registration r INNER JOIN tpt_oe_order_items i ON i.reg_id = r.id INNER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN tpt_offering_action oa on oa.id = r.offering_action_id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name INNER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name INNER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name INNER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name WHERE r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND r.student_id is null AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 AND @@003 is null
UNION
SELECT /* Private - Internal learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , e.id person_id, format_name(e.fname , e.lname , @@005) , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1 , r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN let_pvt_offering_request pvt_offreq ON pvt_offreq.class_id = r.class_id INNER JOIN tpt_offering_action oa on oa.id = r.offering_action_id LEFT OUTER JOIN tpt_oe_order_items i ON i.part_id = pvt_offreq.id LEFT OUTER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id LEFT OUTER JOIN tpt_company c ON e.company_id = c.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name LEFT OUTER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' LEFT OUTER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name AND orderList.list_id = 'sysli000000000000129' AND orderList.locale_id = @@005 LEFT OUTER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name AND approvalList.list_id = 'sysli000000000000165' AND approvalList.locale_id = @@005 WHERE e.type = 100 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003))
UNION
SELECT /* Private - External learner */ r.id reg_id, i.id order_item_id, o.id order_id, o.order_no , e.id person_id, format_name(e.fname , e.lname , @@005) , c.id company_id, c.name2 , ent.id entid, ctype.id ctypeid, ctype.name , i.status , items.description , substr ( i.flags , 1 , 1 ) is_conf , r.status status1, rs.description description1 , r.wlist_priority , r.reg_no , r.flags , o.status status2, o.split, null learnerViewOnly, null statusViewOnly, i.approved_status, decode(substr(r.flags,2,1),'1','true','false') isWalkIn, oa.id offering_action_id, oa.status profile_status ,c.name2 org_name ,ctype.name audience_sub_type ,items.description description ,o.order_no order_no ,orderList.description order_status ,approvalList.description approval_status ,e.fname learner_first_name ,e.lname learner_last_name FROM tpt_registration r INNER JOIN let_pvt_offering_request pvt_offreq ON pvt_offreq.class_id = r.class_id INNER JOIN tpt_offering_action oa on r.offering_action_id = oa.id LEFT OUTER JOIN tpt_oe_order_items i ON i.part_id = pvt_offreq.id LEFT OUTER JOIN tpt_oe_order o ON i.order_id = o.id INNER JOIN cmt_person e ON r.student_id = e.id LEFT OUTER JOIN tpt_company c ON e.company_id = c.id LEFT OUTER JOIN tpt_roster_template_entry ent ON r.ros_temp_ent_id = ent.id LEFT OUTER JOIN tpt_customer_type ctype ON ent.customer_type_id = ctype.id INNER JOIN fgt_ext_sys_list_of_val rs ON to_char ( r.status ) = rs.name LEFT OUTER JOIN fgt_ext_sys_list_of_val items ON to_char ( i.status ) = items.name AND items.locale_id = @@005 AND items.list_id = 'sysli000000000000131' LEFT OUTER JOIN fgt_ext_sys_list_of_val orderList ON to_char ( o.status ) = orderList.name AND orderList.locale_id = @@005 AND orderList.list_id = 'sysli000000000000129' LEFT OUTER JOIN fgt_ext_sys_list_of_val approvalList ON to_char(i.approved_status) = approvalList.name AND approvalList.locale_id = @@005 AND approvalList.list_id = 'sysli000000000000165' WHERE e.type = 200 AND r.class_id = @@001 AND r.status = nvl ( to_number(@@002) , r.status ) AND rs.locale_id = @@005 AND rs.list_id = 'sysli000000000000100' AND ((@@003 is null) or (@@003 is not null and r.student_id = @@003)) ORDER BY 34,35,28,29,31,30,33,32 -
Date Query With Restricted Dates
Sorry not really an easy thing to explain:
I have specified in a Query that i Only want values with a date BETWEEN:
01JAN2002 08:00 AND 01SEP2003 08:00
Now in the same query, what is the simplest way to restrict that only the following dates are examined and not all the dates within the above time window:
Say 06/01 - 07/01
The following dates i am looking to analyze will thus be
01JUN2002 08:00 - 01JUL2002 08:00
01JUN2003 08:00 - 01JUL2003 08:00
ThanksHad a little bit more time to test, today. So in case you couldn't find the complete soultion yourself, here you go. The records with flag='Y' are the ones that fit within your selection criteria (between any 7-OKT 8:00AM and 8-OKT 8:00AM).
drop table testDate;
create table testDate(id number,flag char,yourDate date);
insert into testDate values (1,'Y',to_date('7-OKT-2003 11:00:00','DD-MON-YYYY HH:MI:SS'));
insert into testDate values (2,'Y',to_date('8-OKT-2003 7:00:00','DD-MON-YYYY HH:MI:SS'));
insert into testDate values (3,'N',to_date('7-OKT-2003 3:00:00','DD-MON-YYYY HH:MI:SS'));
insert into testDate values (4,'N',to_date('8-OKT-2003 11:00:00','DD-MON-YYYY HH:MI:SS'));
insert into testDate values (5,'Y',to_date('7-OKT-2002 11:00:00','DD-MON-YYYY HH:MI:SS'));
insert into testDate values (5,'N',to_date('6-OKT-2002 11:00:00','DD-MON-YYYY HH:MI:SS'));
insert into testDate values (5,'N',to_date('9-OKT-2002 11:00:00','DD-MON-YYYY HH:MI:SS'));
commit;
select id,flag,to_char(yourDate,'DD-MON-YYYY HH:MI:SS') from testDate
where trunc(yourDate,'HH')-trunc(yourDate,'YYYY')
between to_date('7-OKT-2003 08:00:00','DD-MON-YYYY HH:MI:SS')-to_date('01-JAN-2003')
and to_date('8-OKT-2003 08:00:00','DD-MON-YYYY HH:MI:SS')-to_date('01-JAN-2003')
/ -
Query with aggregates over collection of trans. instances throws an error
Hi, I'm executing a query with aggregates an it throws an exception with the following message "Queries with aggregates or projections using variables currently cannot be executed in-memory. Either set the javax.jdo.option.IgnoreCache property to true, set IgnoreCache to true for this query,
set the kodo.FlushBeforeQueries property to true, or execute the query before changing any instances in the transaction.
The offending query was on type "class Pago" with filter "productosServicios.contains(item)".
The class Pago has the field productosServicios which is a List of Pago$ItemMonto, the relevant code is :
KodoQuery query = (KodoQuery)pm.newQuery(Pago.class,
pagos);
where pagos is a list of transient instances of type Pago.
query.declareVariables("Pago$ItemMonto item");
query.setFilter("productosServicios.contains(item)");
query.setGrouping("item.id");
query.setResult("item.id as idProductoServicio,
sum(montoTotal) as montoTotal");
query.setResultClass(PagoAgrupado.class);
where the class PagoAgrupado has the corresponding fields idProductoServicio and montoTotal.
In other words, I want to aggregate the id field of class ItemMonto over the instances contained in the productosServicios field of class Pago.
I have set to true the ignoreCache and kodo.FlushBeforeQueries flags in the kodo.properties file and in the instances of the pm and the query but it has not worked, what can be wrong?.
I'm using Kodo 3.2.4, MySQL 5.0
Thanks,
Jaime.
Message was edited by:
jdelajarafThanks, you nailed it! I tried comparing the two files myself, but Bridge told me that the 72.009 dpi document was 72 dpi.
I have no idea why the resolution mess things up, but as long as I know how to avoid the bug, things are grand! -
Infoset query with cero values
Hi
I have an infoset query that reads the information from an infoset. The infoset query is able to read the values, because it shows me values, but everything is cero, although I have values different from 0.
But if it didn`t find values it would tell me a different message as "No application data found" or something like this.
Then the problem is, my infoset read values, but everything that shows me is cero, and that´s not true.
Thanks and regards
SEM SEMHi,
What do you mean with the join condition ?
I have an infoset query with only one ODS inside. I didn´t want to build a query directly to the ODS as I did´t want to mark the flag available for reporting in the ODS, as it already had very importat data and I didn´t want to damage the ODS data. That´s why I have built and infoset query with one ODS inside, and in this case I don´t understand the join condition....
Regards
SEM SEM
Does anybody know something ????
Regards
SEM SEM
Message was edited by:
SEM SEM -
DSO with flag "SIDs Generation upon Activation" deactivated
Situation 1:
I am using a standard DSO. The flag "SIDs Generation upon Activation" is not set. Note 1392715 states:
"... If you deactivate this flag, reporting is still possible since missing SIDS will be created during the query runtime from 7.0..."
Question 1:
What is about characterstic values with already existing SIDS? Are they selected at query runtime? Are SIDS created during query runtime for all characteristic values, even if the characteristic value has got a physical SID in its master table? Gets a query on this DSO faster, when pyhsical SID will exist in the respect master tables?
Situation 2:
I am using an infoobject with flag "attribute only" in a standard DSO. The flag "SIDs Generation upon Activation" is not set in this DSO. This DSO is connected to a virtual virtual provider based on DTP. The query Q1 on the virtual provider reports the infobject with the flag "attribute only". The query Q2 on the DSO doe not report the infoobject with the flag "attribute only".
Question 2:
What is faster? A query on a virtual provider or a query on a DSO with flag "SID Generation upon Activation" is not set.Hi,
Question 1:
What is about characterstic values with already existing SIDS? Are they selected at query runtime? Are SIDS created during query runtime for all characteristic values, even if the characteristic value has got a physical SID in its master table? Gets a query on this DSO faster, when pyhsical SID will exist in the respect master tables?
1. There will be there at base tables. Query runtime it won't select sids.
i think no, it creates sid for the records which don't have sid.
along with sid, its depend on the selections/filters/data volume on dso.
Question 2:
Query will be faster on dso. because virtual provider pulls data during report excution and may take more time than reporting on dso.
Thanks -
How to create an ABAP Query with OR logical expression in the select-where
Hi,
In trying to create an ABAP query with parameters. So it will select data where fields are equal to the parameters entered. The default logical expression is SELECT.. WHERE... AND.. However I want to have an OR logical expression instead of AND.. how can I attain this??
Please help me on this.. Points will be rewarded.
Thanks a lot.
Regards,
Question ManHi Bhupal, Shanthi, and Saipriya,
Thanks for your replies. But that didn't answer my question.
Bhupal,
You cannot just replace AND with OR in an ABAP QUERY. ABAP QUERY is a self generated SAP code. You'll just declare the tables, input parameters and output fields to be displayed and it will create a SAP standard code. If you'll try to change the code and replace the AND with OR in the SAP standard code, the system will require you to enter access key/object key for that particular query.
Shanthi,
Yes, that is exactly what need to have. I need to retireve DATA whenever one of the conditions was satisfied.
Saipriya,
Like what I have said, this is a standard SAP code so we can't do your suggestion.
I have already tried to insert a code in the ABAP query (there's a part there wherein you can have extra code) but that didn't work. Can anybody help me on this.
Thanks a lot.
Points will be rewarded.
Regards,
Question Man -
Error while trying to Execute the Query with Customer Exit
Hi Experts,
I am having a Query with Customer Exit, it is working fine for all the Employess, except for one. When i try to remove the Customer Exit it is working for her too. Below is the error i am getting.
system error in program SAPLLRK0 and form RSRDR; CHECK_NAV_INIT_BACK
Thanks,
Kris.Hello Kris,
Are you working with multiprovider? Please check if OSS notes 813454,840080 or 578948 are applicable in your case.
Regards,
Praveen -
Report on BEx query with 2 structures (one in rows and one in columns)
Hi, experts! I have to make Crystall report on BEx query with 2 structures, one in columns (with KF's), and one in rows. Is it possible to create such report? Because when I create such report, I cant see fields in structures, only characteristics fields.
Ok, I found samr problem in another thread. Sorry.
Edited by: Mikhail Sychev on Dec 5, 2009 9:53 PMHey Flora,
Happy to hear that its working now.
Answering your question, again its upto the connection and report format you are using. Based on your question i hope you your report output should be like this.
You cannot map to two labels for the series, again this report format is possible only in cross tab through Webi. I would suggest you to concatenate the material and month in a dimension in webi like below.
I have done the concatenation in excel level, i would suggest you to do that in webi. Try to reduce the formula as much in excel.
or
If you are using Query browser connection, then i would suggest you to create a separate report which will display the actual vs plan material wise, here you need to pass the material as a prompt.
Hope this helps in clear, please revert me for any clarification. -
Query with bind variable, how can use it in managed bean ?
Hi
I create query with bind variable (BindControlTextValue), this query return description of value that i set in BindControlTextValue variable, how can i use this query in managed bean? I need to set this value in String parameter in managed bean.
ThanksPut the query in a VO and execute it the usual way.
If you need to, you can write a parameterized method in VOImpl that executes the VO query with the parameter and then call that method from the UI (as a methodAction binding) either through the managed bean or via a direct button click on the page. -
Report query with bind variable
Trying to create a report query for xsl-fo print. For output format I pick "derive from item" then pick the item name from the list, on the next screen, I paste the query with the bind variable. on the next step test query, I always get "data not found" regardless what value I type in. This is the same query that I ran under sql commands without any issues.
Does anyone run into the same issue as I have when attempted to create a query with bind var ? There is no problem creating a query without bind varibles. . thanks.
MunsharHi, please did you get any solution to this issue? I am having similar challenge right now.
select EMP.DEPTNO as DEPTNO,
DEPT.DNAME as DNAME,
EMP.EMPNO as EMPNO,
EMP.ENAME as ENAME,
EMP.JOB as JOB,
EMP.MGR as MGR,
EMP.HIREDATE as HIREDATE,
EMP.SAL as SAL
from SCOTT.DEPT DEPT,
SCOTT.EMP EMP
where EMP.DEPTNO=DEPT.DEPTNO
and DEPT.DNAME =upper(:dname)
This run perfectly in sql developer, toad, and even inside publisher if I login directly to publisher to create report.
Generating this same query in shared component query builder and testing it returns no data found. If I remove the last line, it works. but with the last line, it return no data found. It seems no one has been able to provide solution to this issue -
SQL query with Bind variable with slower execution plan
I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
Execution Plan
0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
(Cost=2 Card=135 Bytes=6480)
Statistics
0 recursive calls
18 db block gets
15558 consistent gets
47 physical reads
9896 redo size
423 bytes sent via SQL*Net to client
1095 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
55 rows processed
I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
Execution Plan
0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
Statistics
0 recursive calls
12 db block gets
3003199 consistent gets
54 physical reads
9448 redo size
423 bytes sent via SQL*Net to client
1258 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
55 rows processed
TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
Regards
IvanMany thanks for your reply.
I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
for table I use:-
begin
dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
end;
for index I use:-
begin
dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
end;
Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
regards
Ivan -
Query with tables VEPVG, VBAK, VBAP AND KONV
hi all,
I have a requirement, that is Open Sale Orders which is having Special Discount. I am trying to write a Query, But KONV table is not coming into the joins. my execution plans is bellow
VEPVG --> VBAK vbak-knumv = konv-knumv and konv-kschl = Special Discount
VBAP
Please explain me, how to design the query with conditions.
Thanks & Regards,
SrinivasHi,
Have you referred this help document.
http://help.sap.com/printdocu/core/Print46c/EN/data/pdf/BCSRVQUE/BCSRVQUE.pdf
Regards - Shree -
SQL Report query with condition (multiple parameters) in apex item?
Hello all,
I have a little problem and can't find a solution.
I need to create reports based on a SQL query or I.R. Nothing hard there.
Then I need to add the WHERE clause dynamically with javascript from an Apex item.
Again not very hard. I defined an Apex item, set my query like this "SELECT * FROM MYTAB WHERE COL1 = :P1_SEARCH" and then I call the page setting the P1_SEARCH value. For instance COL1 is rowid. It works fine.
But here is my problem. Let's consider that P1_SEARCH will contain several rowids and that I don't know the number of those values,
(no I won't create a lot of items and build a query with so many OR!), I would like sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (:P1_SEARCH) with something like : ROWID1,ROWID2 in P1_SEARCH.
I also tried : 'ROWID1,ROWID2' and 'ROWID1','ROWID2'
but I can't get anything else than filter error. It works with IN with one value but as soon as there are two values or more, it seems than Apex can't read the string.
How could I do that, please?
Thanks for your help.
Maxmnoscars wrote:
But here is my problem. Let's consider that P1_SEARCH will contain several rowids and that I don't know the number of those values,
(no I won't create a lot of items and build a query with so many OR!), I would like sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (:P1_SEARCH) with something like : ROWID1,ROWID2 in P1_SEARCH.
I also tried : 'ROWID1,ROWID2' and 'ROWID1','ROWID2'
but I can't get anything else than filter error. It works with IN with one value but as soon as there are two values or more, it seems than Apex can't read the string.For a standard report, see +{message:id=9609120}+
For an IR—and improved security avoiding the risk of SQL Injection—use a <a href="http://download.oracle.com/docs/cd/E17556_01/doc/apirefs.40/e15519/apex_collection.htm#CACFAICJ">collection</a> containing the values in a column instead of a CSV list:
{code}
SELECT * FROM MYTAB WHERE ROWID IN (SELECT c001 FROM apex_collections WHERE collection_name = 'P1_SEARCH')
{code}
(Please close duplicate threads spawned by your original question.) -
Broadcast a BW 7.0 query with BW 3.5 broadcaster?
Hi Folks,
is there a trick that allows to broadcast a BW 7.0 query with the BW 3.5 broadcaster?
On the precal server BEX 3.5 / 7.0 is installed so in theory there shouldn't be an issue.
But in the BW 3.5 broadcaster I don't see BEX 7.0 queries as all (for html) nor BEX 7.0 workbooks.
As we don't have BI JAVA stack we don't have BW 7.0 broadcaster ...
Any ideas / workarounds / tricks?
Thanks,
AxelHi,
Pls check the links----
Issues with broadcasting 3.5 workbooks after migration to 7.1
Broadcaster not working from BEX Analyzer 7.0
Not able to broadcast query.
Regards,
Suman
Maybe you are looking for
-
Satellite U400-10J - power is on but NO LCD dsiplay
Good day. I have a new Toshiba Satellite U400-10J. I did not turn it off after i use it and then when i get back it was hanged up so i decided to turn it off by pressing the power button in few seconds. The next day when i decided to use my laptop ag
-
.When installing a CD/album into my library some of the tracks get separated away from the main group of tracks. I try to click and drag the stragglers to the main group but it doesn't work. My laptop is using Windows 8. My old XP laptop didn't have
-
Convert Autonomous to lightweight AP - Static IP Address
Hi, I've converted a couple of Autonomous APs to lightweight recently and once they reboot they have a static IP configured on them, which then requires console access to remove the static IP. Below are the commands I run to convert the AP: AP#archiv
-
What do I have to install with Xmonad ?
I installed Xmonad now what do I do now ? What all apps should I download? Which is the best menu bar? Xmobar or ? where do I go from here on?'do i have to install alsa ? Last edited by pyarch (2011-12-17 23:18:34)
-
Deploy, IIOP connection, Unable to connect to Oracle 8i using IIOP
Hi, I have a working JDBC connection to my Oracle 8i Enterprise DB server but when i try to establish a IIOP connection to the same server i get the following error message: "Can4t find resource for bundle oracle.aurora.jndi.sess_iiop.Messages, key U