A map of OWB (service line) SQL query
If I trace a session, run a map OWB (base line), the trace file contains the actual SQL query?
The problem with me is that when I execute this rank - based OWB card, is throw me an error CursorFetchMapTerminationRTV20007, BUT (most time consuming) when I take on the intermediate SQL insert query, it works very well (and also in a very short time)
The executing State = COMPLETE
message = text ORA-06502: PL/SQL: digital or value error: character string buffer too small
CursorFetchMapTerminationRTV20007 = message text
N ° of task errors = 0
N ° task warnings = 2
N ° errors = 1
Since this card OWB (truncate insert) is the line in function of where I can't back-end of the generated pl/sql package request OWB so I was wondering if I trace the session, check the trace file, maybe I'll able to see the exact SQL query generated. But I wanted to confirm the same.
Yes, the real run SQL in session will be in the trace file.
Tags: Database
Similar Questions
-
SQl query to find out time between the different lines of transactions
(See both images from an attachment to get the clear picture of the data and understand the question correctly.)
I have a set of data like this in one of my paintings. (This is a simple representation of the original data.)
Reference table1.jpg
Id | Type | Value | Start_date | End_date
----------------------------------------------------------------------------------------------------------------------
ZTR0098 | ALLOW | 0 | 1 JUN | 2 JUN |
ZTR0098 | ADTAX | 0 | 1 JUN | 2 JUN |
ZTR0098 | MXTAX | 0 | 1 JUN | 9 JUN |
ZTR0098 | ALLOW | 4. 3 JUN | 15 JUN |
ZTR0098 | ADTAX | 44.00 | 3 JUN | 17-JUNE |
ZTR0098 | MXTAX | 2. 10 JUN | 17-JUNE |
ZTR0098 | ALLOW | 5. 16-JUNE | 20 JUN |
ZTR0098 | ADTAX | 55,34 | 18 JUN | 22 JUN |
ZTR0098 | MXTAX | 1. 18 JUN | 25 JUN |
ZTR0098 | MXTAX | 6. 26 JUN | 31 AUG |
ZTR0098 | ADTAX | 20.09. 23 JUN | 23 JUL |
ZTR0098 | ALLOW | 8. 21 JUN | 31 AUG |
ZTR0098 | ADTAX | 45. 24 JUL | 31 AUG |
each line has a type and a rasthaus id to it. ID belongs to other parent tables. the value of each type is given, and the validity of each value is followed by a field start_date and end_date.
All values start from 1 - JUN and expires on 31 - AUG. Now my requirement is to obtain a report that gives three columns for three different types (ALLOW, ADTAX and MXTAX) with combination of unique values in the effective time interval. Let me put the result below.
Reference table2.jpg
Id | ALLOW | ADTAX | MXTAX | Start_date | End_date
--------------------------------------------------------------------------------------------------------------------------------------------------
ZTR0098 | 0 | 0 | 0 | 1 JUN | 2 JUN |
ZTR0098 | 4. 44.00 | 0 | 3 JUN | 9 JUN |
ZTR0098 | 4. 44.00 | 2. 10 JUN | 15 JUN |
ZTR0098 | 5. 44.00 | 2. 16-JUNE | 17-JUNE |
ZTR0098 | 5. 55,34 | 1. 18 JUN | 20 JUN |
ZTR0098 | 8. 55,34 | 1. 21 JUN | 22 JUN |
ZTR0098 | 8. 20.09. 1. 23 JUN | 25 JUN |
ZTR0098 | 8. 20.09. 6. 26 JUN | 23 JUL |
ZTR0098 | 8. 45. 6. 23 JUL | 31 AUG |
As you can see there are no duplicate rows for a combination of (ALLOW, ADTAX and MXTAX) with their respective dates in force. resulting in the above table. the first step is to convert lines to the column which is pretty obvious to do that by grouping on start_date and end_date colum, but the real deal is the time interval during which the combination of the values (ALLOW, ADTAX, and MXTAX) has remained constant.
I wrote under query using Group by.
Select
ID,
NVL (max (decode (type, "ALLOW", value)), 0) as ALLOW
NVL (max (decode (type, 'ADTAX', value)), 0) as ADTAX
NVL (max (decode (type, 'MXTAX', value)), 0) as MXTAX
Start_date,
End_date
from my_table
Group of start_date, end_date, id
start_date, end_date
the results it gives are like this:
Reference table3.jpg
Id | ALLOW | ADTAX | MXTAX | Start_date | End_date
------------------------------------------------------------------------------------------------------------------------------------------------
ZTR0098 | 0 | 0 | 0 | 1 JUN | 2 JUN |
ZTR0098 | 0 | 0 | 2. 1 JUN | 9 JUN |
ZTR0098 | 4. 0 | 0 | 3 JUN | 15 JUN |
ZTR0098 | 0 | 44.00 | 0 | 3 JUN | 17-JUNE |
ZTR0098 | 0 | 0 | 2. 10 JUN | 17-JUNE |
ZTR0098 | 5. 0 | 0 | 16-JUNE | 20 JUN |
ZTR0098 | 0 | 55,34 | 0 | 18 JUN | 22 JUN |
. .
. .
like wise
but I'm not able to determine the time intervals by using the SQL query.
with
Table1 as
(select the id 'ZTR0098', 'ALLOW' type, 0 val, to_date('1-JUN','dd-MON') start_date, end_date Union to_date('2-JUN','dd-MON') double all the)
Select 'ZTR0098', 'ADTAX', 0, to_date('1-JUN','dd-MON'), to_date('2-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'MXTAX', 0, to_date('1-JUN','dd-MON'), to_date('9-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'ALLOW', 4, to_date('3-JUN','dd-MON'), to_date('15-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'ADTAX', 44.00, to_date('3-JUN','dd-MON'), to_date('17-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'MXTAX', 2, to_date('10-JUN','dd-MON'), to_date('17-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'ALLOW', 5, to_date('16-JUN','dd-MON'), to_date('20-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'ADTAX', 55.34, to_date('18-JUN','dd-MON'), to_date('22-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'MXTAX', 1, to_date('18-JUN','dd-MON'), to_date('25-JUN','dd-MON') of all the double union
Select 'ZTR0098', 'MXTAX', 6, to_date('26-JUN','dd-MON'), to_date('31-AUG','dd-MON') of all the double union
Select 'ZTR0098', 'ADTAX', 20.09, to_date('23-JUN','dd-MON'), to_date('23-JUL','dd-MON') of all the double union
Select 'ZTR0098', 'ALLOW', 8, to_date('21-JUN','dd-MON'), to_date('31-AUG','dd-MON') of all the double union
Select 'ZTR0098', 'ADTAX', 45, to_date('24-JUL','dd-MON'), to_date('31-AUG','dd-MON') of the double
),
days like
(select level - 1 dte + to_date('1-JUN','dd-MON')
of the double
connect by level<= to_date('31-aug','dd-mon')="" -="" to_date('1-jun','dd-mon')="" +="">=>
)
Select id, allow, adtax, mxtax, min (dte) start_date, max (dte) end_date
(select ID, dte, max (allow) allow, max (adtax) adtax, max (mxtax) mxtax,
ROW_NUMBER() over (order by dte) row_number() - courses (partition by order max (allow), max (adtax), max (mxtax) by dte) gr
go (select id, dte,
-case when type = 'ALLOW' and dte between start_date and end_date then end val 0 otherwise allow.
-case when type = "ADTAX" and dte between start_date and end_date then val 0 otherwise end adtax.
-case when type = "MXTAX" and dte between start_date and end_date then val 0 otherwise end mxtax
Table 1 t,
days d
where d.dte between t.start_date and t.end_date
)
Group by id, dte
)
Group by id, gr, allow, adtax, mxtax
order by id, gr
ID ALLOW ADTAX MXTAX START_DATE END_DATE ZTR0098 0 0 0 01/06/2015 02/06/2015 ZTR0098 4 44 0 03/06/2015 09/06/2015 ZTR0098 4 44 2 10/06/2015 15/06/2015 ZTR0098 5 44 2 16/06/2015 17/06/2015 ZTR0098 5 55,34 1 18/06/2015 20/06/2015 ZTR0098 8 55,34 1 21/06/2015 22/06/2015 ZTR0098 8 20.09 1 23/06/2015 25/06/2015 ZTR0098 8 20.09 6 26/06/2015 23/07/2015 ZTR0098 8 45 6 24/07/2015 31/08/2015 Concerning
Etbin
-
Write a SQL query with lines in columns
All the
I need help in writing a SQL query with lines in columns, let give u an example...
drop table activity;
CREATE TABLE 'ACTIVITY '.
(
"PROJECT_WID" NUMBER (22.0) NOT NULL,
VARCHAR2 (150 CHAR) "PROJECT_NO."
VARCHAR2 (800 CHAR) 'NAME '.
);
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1683691, '10007', 12-121');
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1684994, '10008', 12-122');
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1686296, '10009', 12-123');
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (2225222, '9040', 12-124');
drop table lonet;
CREATE TABLE 'LONET.
(
VARCHAR2 (150 CHAR) "NAME."
NUMBER OF THE "ROOT."
VARCHAR2 (150 CHAR) "ENTRYVALUE".
);
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1683691, "LDE");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1683691, 'LME');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1683691, 'ICE');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1683691, 'IKE');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1686291, "QTY");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1686291, 'MAX');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1684994, "MTE");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1684994, 'MAC');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMT', 1684994, 'NICE');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMR', 1684994, 'RAY');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1686296, "CAQ");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("PAP", 1686296, "QAQ");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("VANESSA", 1686296, "THEW");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("ANDR", 1686296, "REYL");
commit;
Link: activity.project_wid = lonet.root
look like output
Project_wid Project_no NAME GAC NAM BAG RAC 1683691 10007 12-121 LDE LME LCE LKE 1684994 10008 12-122 MTE null null MAC 1686296 10009 12-123 null null CAQ QAQ 2225222 9040 12-124 null null null null two problems, in that I am running
1. I dono how simply we can convert rows to columns
2. for root = 1683691, there are double NAM and RAC in lonet table... ideally these data should not be there, but since its here, we can take a MAX so that it returns a value
3. There are undesirables who should be ignored
Once again my thought process is that we join the activity and 4 alias table lonet.
ask for your help in this
Thank you
Hello
This is called pivoting.
Here's a way to do it:
WITH relevant_data AS
(
SELECT a.project_wid, a.project_no, b.SID
, l.name AS lonet_name, l.entryvalue
Activity one
LEFT OUTER JOIN lonet l.root = a.project_wid l
)
SELECT *.
OF relevant_data
PIVOT (MAX (entryvalue)
FOR lonet_name IN ("GAC" IN the gac
"NAM" AS nam
'BAG' IN the bag
"RAC" AS cars
)
)
ORDER BY project_wid
;
Output:
PROJECT_WID PROJECT_NO GAC NAM BAG RAC NAME
----------- ---------- ---------- ---------- ---------- ---------- ----------
1683691 12 - 10007 121 LDE LME LCE LKE
1684994 MAC MTE 10008 12-122
1686296 12 - 10009 123 QAC QAQ
2225222 9040 12 - 124
To learn more about swivel, see the FAQ in the Forum: Re: 4. How can I convert rows to columns?
Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!
-
Hi all..
It's SOA 11.1.1.7... I created the schema and storage via RCU but when I try to configure JDBS schema components... his throw this error:
CFGFWK-60850: the Test failed!
CFGFWK-60853: A connection to the database, but no lines have been returned to the examination of the SQL query.
I created 3 users of UCR and who were all successful, because I have no error... of these three alone is managed in the configuration tree SOA...
No idea why like that...
Thank you
Aerts
This that I solved it by installing EMP 11.1.2.2 with UCR and SOA 11.1.1.6...
-
SQL query for the mapping of a set of prizes to a group of classrooms
Hi all
I use Oracle database 11g Release 2.
I have the following data set:
Classrooms
ClassId ClassName ability group
------ ---------------------------------------------- -------------- -----------
Babbage/software Engg Lab 1 24 1
Basement 2 - block PG 63 1
3 1 56 1 class
Class 4 1 24 10
Class 5 1 24 11
Class 6 1 35 12
7 13 42 1 class
8 14 42 1 class
9 15 42 1 class
10 2 35 1 class
11 3 35 1 class
12 4 35 1 classroom
13 5 35 1 class
14 6 25 1 class
15 7 25 1 class
16 1 24 8 class
17 9 24 1 class
18 control Sys Lab 1 24
19 dig & Embd Sys Lab 20 1
20 PSD & Comm 20 1 Lab
21 electromechanical system Lab 28 1
Farabi 22/Web Tech Lab 1 36
23 gen purpose Lab 40 1
Shirazi/24dB Tech Lab 1 36
ADV 25 elect Lab 30 2
26 16 42 2 class
27 17 49 2 class
28 18 56 2 class
29 19 42 2 class
30 20 49 2 class
Class 31 21 35 3
32 22 35 3 class
33 20 3 MDA lab
DegreeBatches
BatchId BatchName force
--------------- ----------------------- --------------
1 BIT - 11 79
2 BIT - 12 28
3 BS (CS)-1 35
4 BS (CS) 78-2
5 BE (SE)-1 69
6. BE (SE) 84-2
7 BE (SE) 64-3
8 84 BYTČA-7
9 43 BYTČA-8
BEE-1 10, 112
11 151 BEE-2
BEE-3 12, 157
13 BEE-4 157
I want to map a combination of batch of degree for a class rooms group of such distance that they make full use of the maximum capacity of the class rooms within a group (ideally), or as close to this as possible. Can it be done with a SQL query?
Any response will be appreciated.
The SQL Scripts to generate the required tables and populate data is less to:
CREATE TABLE classrooms (ClassId NUMBER, ClassName VARCHAR2 (50), capacity NUMBER, group NUMBER);
INSERT INTO the classrooms of the VALUES (1, "Babbage/software Engg Lab', 24, 1");
INSERT INTO the classrooms of the VALUES (2, 'basement - PG block', 63, 1);
INSERT INTO the classrooms of the VALUES (3, '1 class room', 56, 1);
INSERT INTO the classrooms of the VALUES (4, '10 class room', 24, 1);
INSERT INTO the classrooms of the VALUES (5, '11 class room', 24, 1);
INSERT INTO the classrooms of the VALUES (6, 'class room 12', 35, 1);
INSERT INTO the classrooms of the VALUES (7, 'class room 13', 42, 1);
INSERT INTO the classrooms of the VALUES (8, 'class room 14', 42, 1);
INSERT INTO the classrooms of the VALUES (9, '15 'class, 42, 1);
INSERT INTO the classrooms of the VALUES (10, 'class 2', 35, 1);
INSERT INTO the classrooms of the VALUES (11, 'class room 3', 35, 1);
INSERT INTO the classrooms of the VALUES (12, 'class room 4', 35, 1);
INSERT INTO the classrooms of the VALUES (13, 'class room 5', 35, 1);
INSERT INTO the classrooms of the VALUES (14, 'class room 6', 25, 1);
INSERT INTO the classrooms of the VALUES (15, '7 class room', 25, 1);
INSERT INTO the classrooms of the VALUES (16, 'class Room 8', 24, 1);
INSERT INTO the classrooms of the VALUES (17, 'class room 9', 24, 1);
INSERT INTO the classrooms of the VALUES (18, 'Control Sys Lab', 24, 1);
INSERT INTO the classrooms of the VALUES (19, 'Dig & Embd Sys Lab', 20, 1);
INSERT INTO the classrooms of the VALUES (20, 'DSP & Comm Lab', 20, 1);
INSERT INTO the classrooms of the VALUES (21, 'system ELECTROMECHANICAL Lab', 28, 1);
INSERT INTO the classrooms of the VALUES (22, ' Farabi/Web Tech Lab', 36, 1);
INSERT INTO the classrooms of the VALUES (23, 'Gen purpose Lab', 40, 1);
INSERT INTO the classrooms of the VALUES (24, ' Shirazi/DB Tech Lab', 36, 1);
INSERT INTO the classrooms of the VALUES (25, 'Elected Adv Lab', 30, 2);
INSERT INTO the classrooms of the VALUES (26, 'class room 16', 42, 2);
INSERT INTO the classrooms of the VALUES (27, 'class room 17', 49, 2);
INSERT INTO the classrooms of the VALUES (28, '18 'class, 56, 2);
INSERT INTO the classrooms of the VALUES (29, '19 'class, 42, 2);
INSERT INTO the classrooms of the VALUES (30, 'class room 20', 49, 2);
INSERT INTO the classrooms of the VALUES (31, 'class room 21', 35, 3);
INSERT INTO the classrooms of the VALUES (32, 'room 22', 35, 3);
INSERT INTO the classrooms of the VALUES (33, 'MDA Lab', 20, 3);
CREATE TABLE DegreeBatches (BatchId NUMBER, BatchName VARCHAR2 (50), membership NUMBER);
INSERT INTO DegreeBatches VALUES(1,'BIT-11',79);
INSERT INTO DegreeBatches VALUES(2,'BIT-12',28);
INSERT INTO DegreeBatches VALUES (3, 'BS (CS) - 1', 35);
INSERT INTO DegreeBatches VALUES (4, 'BS (CS) - 2', 78);
INSERT INTO DegreeBatches VALUES (5,'BE (SE) - 1', 69);
INSERT INTO DegreeBatches VALUES (6,'BE (SE) - 2', 84);
INSERT INTO DegreeBatches VALUES (7,'BE (SE) - 3', 64);
INSERT INTO DegreeBatches VALUES(8,'BICSE-7',84);
INSERT INTO DegreeBatches VALUES(9,'BICSE-8',43);
INSERT INTO DegreeBatches VALUES(10,'BEE-1',112);
INSERT INTO DegreeBatches VALUES(11,'BEE-2',151);
INSERT INTO DegreeBatches VALUES(12,'BEE-3',157);
INSERT INTO DegreeBatches VALUES(13,'BEE-4',157);
Best regards
Bilal
Published by: Bilal on December 27, 2012 09:52
Published by: Bilal on December 27, 2012 10:07Bilal, thanks for the nice problem! Another possibility to double check is to write a small PL/SQL function that returns 1 if a duplicate id is found, then equate to 0: "NUMBER of RETURN of Duplicate_Token_Found (p_str_main in VARCHAR2, p_str_trial VARCHAR2). It should analyze the second string and could use p_str_main LIKE '%', | l_id | ', %' for each id. In any case, the query complete (without that) is given below:
Solution with names SQL> WITH rsf_itm (con_id, max_weight, nxt_id, lev, tot_weight, tot_profit, path, root_id, lev_1_id) AS ( 2 SELECT c.id, 3 c.max_weight, 4 i.id, 5 0, 6 i.item_weight, 7 i.item_profit, 8 ',' || i.id || ',', 9 i.id, 10 0 11 FROM items i 12 CROSS JOIN containers c 13 UNION ALL 14 SELECT r.con_id, 15 r.max_weight, 16 i.id, 17 r.lev + 1, 18 r.tot_weight + i.item_weight, 19 r.tot_profit + i.item_profit, 20 r.path || i.id || ',', 21 r.root_id, 22 CASE WHEN r.lev = 0 THEN i.id ELSE r.nxt_id END 23 FROM rsf_itm r 24 JOIN items i 25 ON i.id > r.nxt_id 26 AND r.tot_weight + i.item_weight <= r.max_weight 27 ORDER BY 1, 2 28 ) SEARCH DEPTH FIRST BY nxt_id SET line_no 29 , rsf_con (nxt_con_id, nxt_line_no, con_path, itm_path, tot_weight, tot_profit, lev) AS ( 30 SELECT con_id, 31 line_no, 32 To_Char(con_id), 33 ':' || con_id || '-' || (lev + 1) || ':' || path, 34 tot_weight, 35 tot_profit, 36 0 37 FROM rsf_itm 38 UNION ALL 39 SELECT r_i.con_id, 40 r_i.line_no, 41 r_c.con_path || ',' || r_i.con_id, 42 r_c.itm_path || ':' || r_i.con_id || '-' || (r_i.lev + 1) || ':' || r_i.path, 43 r_c.tot_weight + r_i.tot_weight, 44 r_c.tot_profit + r_i.tot_profit, 45 r_c.lev + 1 46 FROM rsf_con r_c 47 JOIN rsf_itm r_i 48 ON r_i.con_id > r_c.nxt_con_id 49 WHERE r_c.itm_path NOT LIKE '%,' || r_i.root_id || ',%' 50 AND r_c.itm_path NOT LIKE '%,' || r_i.lev_1_id || ',%' 51 AND r_c.itm_path NOT LIKE '%,' || r_i.nxt_id || ',%' 52 ) 53 , paths_ranked AS ( 54 SELECT itm_path || ':' itm_path, tot_weight, tot_profit, lev + 1 n_cons, 55 Rank () OVER (ORDER BY tot_profit DESC) rnk, 56 Row_Number () OVER (ORDER BY tot_profit DESC) sol_id 57 FROM rsf_con 58 ), best_paths AS ( 59 SELECT itm_path, tot_weight, tot_profit, n_cons, sol_id 60 FROM paths_ranked 61 WHERE rnk = 1 62 ), row_gen AS ( 63 SELECT LEVEL lev 64 FROM DUAL 65 CONNECT BY LEVEL <= (SELECT Count(*) FROM items) 66 ), con_v AS ( 67 SELECT b.itm_path, r.lev con_ind, b.sol_id, b.tot_weight, b.tot_profit, 68 Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev - 1) + 1, 69 Instr (b.itm_path, ':', 1, 2*r.lev) - Instr (b.itm_path, ':', 1, 2*r.lev - 1) - 1) 70 con_nit_id, 71 Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev) + 1, 72 Instr (b.itm_path, ':', 1, 2*r.lev + 1) - Instr (b.itm_path, ':', 1, 2*r.lev) - 1) 73 itm_str 74 FROM best_paths b 75 JOIN row_gen r 76 ON r.lev <= b.n_cons 77 ), con_split AS ( 78 SELECT itm_path, con_ind, sol_id, tot_weight, tot_profit, 79 Substr (con_nit_id, 1, Instr (con_nit_id, '-', 1) - 1) con_id, 80 Substr (con_nit_id, Instr (con_nit_id, '-', 1) + 1) n_items, 81 itm_str 82 FROM con_v 83 ), itm_v AS ( 84 SELECT c.itm_path, c.con_ind, c.sol_id, c.con_id, c.tot_weight, c.tot_profit, 85 Substr (c.itm_str, Instr (c.itm_str, ',', 1, r.lev) + 1, 86 Instr (c.itm_str, ',', 1, r.lev + 1) - Instr (c.itm_str, ',', 1, r.lev) - 1) 87 itm_id 88 FROM con_split c 89 JOIN row_gen r 90 ON r.lev <= c.n_items 91 ) 92 SELECT v.sol_id, 93 v.tot_weight s_wt, v.tot_profit s_pr, c.id c_id, c.name c_name, c.max_weight m_wt, 94 Sum (i.item_weight) OVER (PARTITION BY v.sol_id, c.id) c_wt, 95 i.id i_id, i.name i_name, i.item_weight i_wt, i.item_profit i_pr 96 FROM itm_v v 97 JOIN containers c 98 ON c.id = To_Number (v.con_id) 99 JOIN items i 100 ON i.id = To_Number (v.itm_id) 101 ORDER BY sol_id, con_id, itm_id 102 / SOL_ID S_WT S_PR C_ID C_NAME M_WT C_WT I_ID I_NAME I_WT I_PR ---------- ---- ---- ----- --------------- ---- ---- ----- ---------- ---- ---- 1 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 2 BIT-11 40 40 6 BICSE-7 25 25 2 IAEC Building 70 70 4 BSCS-3 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 3 BSCS-2 35 35 5 BEE-4 50 50 2 255 255 1 SEECS UG Block 100 95 4 BSCS-3 40 40 6 BICSE-7 25 25 7 BESE-3 30 30 2 IAEC Building 70 70 1 BIT-10 35 35 3 BSCS-2 35 35 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 3 255 255 1 SEECS UG Block 100 100 3 BSCS-2 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 65 1 BIT-10 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 4 255 255 1 SEECS UG Block 100 100 3 BSCS-2 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 70 2 BIT-11 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 1 BIT-10 35 35 5 BEE-4 50 50 5 255 255 1 SEECS UG Block 100 95 2 BIT-11 40 40 6 BICSE-7 25 25 7 BESE-3 30 30 2 IAEC Building 70 70 1 BIT-10 35 35 3 BSCS-2 35 35 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 6 255 255 1 SEECS UG Block 100 100 2 BIT-11 40 40 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 65 1 BIT-10 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 7 255 255 1 SEECS UG Block 100 100 2 BIT-11 40 40 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 70 4 BSCS-3 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 1 BIT-10 35 35 5 BEE-4 50 50 8 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 70 2 BIT-11 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 3 BSCS-2 35 35 5 BEE-4 50 50 9 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 65 3 BSCS-2 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 10 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 3 BSCS-2 35 35 7 BESE-3 30 30 2 IAEC Building 70 65 2 BIT-11 40 40 6 BICSE-7 25 25 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 11 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 3 BSCS-2 35 35 7 BESE-3 30 30 2 IAEC Building 70 65 4 BSCS-3 40 40 6 BICSE-7 25 25 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 12 255 255 1 SEECS UG Block 100 95 1 BIT-10 35 35 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 70 2 BIT-11 40 40 7 BESE-3 30 30 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 13 255 255 1 SEECS UG Block 100 95 1 BIT-10 35 35 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 70 4 BSCS-3 40 40 7 BESE-3 30 30 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 14 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 2 BIT-11 40 40 6 BICSE-7 25 25 2 IAEC Building 70 65 3 BSCS-2 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 98 rows selected. Elapsed: 00:00:01.42
Published by: BrendanP on January 20, 2013 11:25
I found the need to deduplicate regular expression:AND RegExp_Instr (r_c.itm_path | r_i.path, ',(\d+),.*?,\1,') = 0)
-
SQL query returns no row vs. multiple lines
Hello
I am trying to get the result of a simple sql query,
If there is no row returned, he would have "No. ROWS" in the result set.
Other wise all the rows containing data is necessary.
Let me know how this could be achieved. Under query works for the latter and not first case as mentioned below
OUTPUT
+ (box 1) when we use B_ID = 123456 +.
IDS
-----
'NO LINE '.
+ (box 2) when we use B_ID = 12345 +.
IDS
-----
1 11112345
2 22212345
create table TEMP_AAA ( A_ID VARCHAR2(10), B_ID VARCHAR2(10) ) INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('111','12345'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('222','12345'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('333','12000'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('444','10000');
WITH MATCH_ROWS AS ( SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID=12345 ), MATCH_ROW_COUNT AS ( SELECT COUNT(1) AS COUNTS FROM MATCH_ROWS ), PROCESSED_ROWS AS ( SELECT CASE WHEN COUNTS = 0 THEN (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID=12345),'NO ROWS') IDS FROM DUAL) ELSE MATCH_ROWS.IDS END IDS FROM MATCH_ROWS,MATCH_ROW_COUNT ) SELECT * FROM PROCESSED_ROWS;
Hello
I think you want to put this on a report or something. I have what would be easier to do this logic there. But if you want that this is possible.
Like thiswith temp_aaa as (select '111' a_id ,'12345' b_id from dual union all select '222' ,'12345' from dual union all select '333' ,'12000' from dual union all select '444' ,'10000' from dual ) , wanted_rows as ( select '123456' B_ID from dual) select temp_aaa.A_ID || temp_aaa.B_ID IDS from temp_aaa ,wanted_rows where temp_aaa.b_id = wanted_rows.b_id union all select 'NO ROWS' FROM DUAL WHERE (SELECT COUNT(*) FROM TEMP_AAA, wanted_rows WHERE TEMP_AAA.B_ID = wanted_rows.B_ID) = 0
In addition, you mix var and number of always use the same type or convert explicitly (to_number or to_char)
WITH MATCH_ROWS AS ( SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID =12345 -- varchar2(10) number ), ...
And again in the
THEN (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID =12345),'NO ROWS') IDS FROM DUAL) -- varchar2(10) number
Kind regards
Peter
-
How to get the line number in the line itself in the Sql query?
Hello
I pick up some lines of a sql query. Is it possible to get line number in each line while all lines are read?
Like this:
RowNum data1 data2
1 abc era
2 NBH ioiYes.
ROWNUM
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/pseudocolumns009.htm#SQLRF00255
select rownum, data1, data2 from yourtable;
-
Report of update SQL query with line selector. Update process.
I have a report of update SQL query with the selectors in line.
How to identify line selector in a process update on the page.
I want to update some columns with a value of an area of selection on the page.
With the help of the base:
UPDATE table_name
SET Column1 = value
WHERE some_column = some_value
I would need to do:
UPDATE table_name
SET column1 =: P1_select
WHERE [line selector] =?
Now sure how to identify [line selector] and/or validate it is checked.
Thank you
BobIdentify the name of the checkbox of the source of the page element, it should be of the fxx format (f01, f02... f50).
Suppose that we f01.for i in 1 .. apex_application.g_f01.count loop UPDATE CONTRACTS SET SIP_LOAD_FLAG = :P16_STATUS where
= apex_application.g_f01(i); --i'th checked record' primary key end loop; -
I encountered a bug in JDeveloper 12.1.3.0.0 when working with custom views of SQL query. The bug manifests itself so that the wizard does not all SQL attributes add to the list of attributes. This is the query that I managed to recreate my original query that shows the bug:
with with_clause as)
Select ao.owner as variable_attr from sys.all_objects ao
)
Select
0 as constant_attr,
WC.variable_attr
of with_clause wc
The wizard creates only an attribute to "constant_attr" and not "variable_attr". Hit the "Requester" button in the wizard gives me the following error:
I don't think I need to stress is how problematic - creation all attributes by hand for a query validates is enough of a reason to go get another IDE because ADF assistants are the most useful features of JDeveloper, otherwise the only ones that are "hooked". In addition, it works very well in JDeveloper 11 g and JDeveloper 10 g - what happened to 12 c?
Oracle has made some changes in this area in 12.1.3. If you have a support contract, you must file an SR with support.oracle.com. If you haven't you might want this folder on https://java.net/jira/browse/ADFEMG that has no attached ALS but at least the problem is registered and if it is accepted as a bug an official bug is triggered.
Timo
-
Hi team,
I'm looking for a SQL query check data (ECC + CallVariable) due to a RESULT of SCRIPT EXECUTE when you ask an external VRU with a translation route to VRU with a 'run external Script '.
In my view, that the data are analyzed between the termination call detail + termination call Variable.
If you have already such a SQL query I would be very grateful to have.
Thanks and greetings
Nick
Omar,
respectfully, shorten the interval of a day might not be an option for a history report ;-)
I recommend to take a look at the following SQL query:
DECLARE @dateFrom DATETIME, @dateTo DATETIME
SET @dateFrom = ' 2014-01-24 00:00:00 '
SET @dateTo = ' 2014-01-25 00:00:00 '
SELECT
TCV. DateTime,
TCD. RecoveryKey,
TCD. RouterCallKeyDay,
TCD. RouterCallKey,
VME. EnterpriseName AS [ECVEnterpriseName],
TCV. ArrayIndex,
TCV. ECCValue
OF Termination_Call_Variable tcv
JOIN THE
(SELECT RouterCallKeyDay, RouterCallKey, RecoveryKey IN Termination_Call_Detail WHERE DateTime > @dateFrom AND DateTime)< @dateto)="">
THE tcv. TCDRecoveryKey = tcd. RecoveryKey
LEFT OUTER JOIN Expanded_Call_Variable VME ON tcv. ExpandedCallVariableID = VME. ExpandedCallVariableID
WHERE the tcv. DateTime > @dateFrom AND tcv. DateTime<>
With variables, you can set up your code (for example, you could write SET @dateFrom =? and let the calling application to fill in the DateTime for you).
In addition, join two large tables with all the lines, as you did (TCD - TCV) is never a good option.
Another aspect to consider: all the ECC is actually arrays (always), is not good to leave aside the index value (tcv. ArrayIndex).
G.
-
DA on updatable report items Sql query using the class
Request Express 4.2.5.00.08
10-11 g Oracle
I have a page, so it has a link/button when he clicks then modal region will appear. Modal region has a as a table (Type SQL Query (updateable report)). All work very well so far.
However, I've now added some complex things.
for example. My region is based on the query of SQL Type (editable report).
SELECT id, name of family, Traghetti, area, d_date, start_time, End_time, displacement, role of table where id =: P10_ID;
I can also add a new line of course.
My problem is, (point) Shift display based on the value of Start_Time point) and so I made sure the class for two items.
for example, Start_Time (' class = "st_tm" ') and Maj ('class to = "Shift_time" '). Start_Time is based on (LOV) and shift is off the point in the sql query, but change the Start_Time.
And now, I created the DA.
1. event: change
Selection type: jQuery Selector
jQuery Selector: .st_tm
Condition: No.
1. action: set value
Set type: Expression Javascript
The JavaScript Expression: $(this.triggeringElement) .val ();
The element affected: P10_X1 (it is a hidden item)
2. action: Plsql Code
Code: start to null; end;
Page items to submit: P10_X1
3. action: Plsql Code
Code: start
If: P10_X1 between '03' AND '11' then
: P10_X1: = 'EARLIES ';
elsif: P10_X1 then '12' and '18'
: P10_X1: = 'LATES ';
on the other
: P10_X1: = 'NIGHTS';
end if;
end;
Page items to submit: P10_X1
NOW another DA
Event: change
Article (s) P10_X1
Condition (in list)
value (HASTY, LATES, NIGHTS)
Action:
Set type: Expression Javascript
The JavaScript Expression: $(this.triggeringElement) .val ();
Affected item:
Selection type: jQuery Selector
jQuery Selector:. Shift_time
Well, I look forward all the above work well, but I'm having a problem.
If I have more than 1 lines on a modal region and if I change the Start_Time value for a row then MAJ (point) is changing but he effect on all lines.
I want, if I make the changes on the line line # 2 while only 2 # MAJ (point) must be not performed any other lines?
Help, please!
Kind regards
RI
I found the solution me thank you.
I removed all the DA mentioned above and created a new.
1. event: change
Selection type: jQuery Selector
jQuery Selector: .st_tm
Condition: No.
Scope of the event: dynamic and light on page load.
Action (Javascript code)
ROW_ID = $(this.triggeringElement).attr('id').substr (4);
If ($(this.triggeringElement). val() > = 03 &. val() $(this.triggeringElement))<= 11)="">=>
.Val ('EARLIES') $(«#f11_» + row_id);
}
ElseIf ($(this.triggeringElement). > 11 val() & $(this.triggeringElement). val())<= 18)="">=>
.Val ('LATES') $(«#f11_» + row_id);
}
ElseIf (. val() > $19 (this.triggeringElement)) {}
.Val ('NIGHTS') $(«#f11_» + row_id);
}
also created another DA because I have a disabled report items.
Event: before the page is sent.
$('_:_disabled').removeAttr ("disabled");
and finally created manual process of DML for tabular and everything works fine. (Insert, Update, and delete).
Kind regards.
-
SQL query to display the sum of the values of each June and December
Hello having problems of construction of a query to the list SQL query to display the sum of the values of each June and December each year.
My Table;
TABLE name: MONTH_TERM
Fields with values:
TERM_KEY MONTH_ACTUAL MONTH_DATE 82 500 01/11/2015 0:00 82 450 01/12/2015 0:00 82 405 01/01/2016 0:00 82 400 01/02/2016 0:00 82 450 01/03/2016 0:00 82 425 01/04/2016 0:00 82 435 01/05/2016 0:00 82 410 06/01/2016 0:00 82 409 01/07/2016 0:00 82 415 01/08/2016 0:00 82 420 09/01/2016 0:00 82 422 10/01/2016 0:00 82 436 11/01/2016 0:00 82 556 01/12/2016 0:00 82 568 01/01/2017 0:00 82 624 02/01/2017 0:00 What I would like to see in a query result:
TERM_KEY MONTH_ACTUAL MONTH_DATE Total of 6 months 82 500 01/11/2015 0:00 82 450 01/12/2015 0:00 950 82 405 01/01/2016 0:00 82 400 01/02/2016 0:00 82 450 01/03/2016 0:00 82 425 01/04/2016 0:00 82 435 01/05/2016 0:00 82 410 06/01/2016 0:00 2525 82 409 01/07/2016 0:00 82 415 01/08/2016 0:00 82 420 09/01/2016 0:00 82 422 10/01/2016 0:00 82 436 11/01/2016 0:00 82 556 01/12/2016 0:00 2658 82 568 01/01/2017 0:00 82 624 02/01/2017 0:00 ---
Here's my query:
Select
"TERM_KEY,"
"MONTH_ACTUAL,"
to_char(MONTH_DATE,'MM/YYYY') MONTH_DATE,
DEAL to_char (MONTH_DATE, 'MM')
WHEN '06' THEN (SELECT SUM (MONTH_ACTUAL)
OF MONTH_TERM
WHERE the to_char (MONTH_DATE, 'MM') between 1 and 6
AND term_key = 82)
WHEN '12' THEN (SELECT SUM (MONTH_ACTUAL)
OF MONTH_TERM
WHERE the to_char (MONTH_DATE, 'MM') between 7 and 12
AND term_key = 82)
ELSE null
END as SIX_MO_CUMM,
of MONTH_TERM
where term_key = 82
It's my results:
TERM_KEY MONTH_ACTUAL MONTH_DATE Total of 6 months 82 500 01/11/15 0:00 82 450 01/12/15 0:00 3608 82 405 01/01/16 0:00 82 400 01/02/16 0:00 82 450 01/03/16 0:00 82 425 01/04/16 0:00 82 435 01/05/16 0:00 82 410 01/06/16 0:00 3717 82 409 01/07/16 0:00 82 415 01/08/16 0:00 82 420 01/09/16 0:00 82 422 10/01/16 0:00 82 436 01/11/16 0:00 82 556 01/12/16 0:00 3608 82 568 01/01/17 0:00 82 624 01/02/17 0:00 Any ideas on how to fix would be great
Select term_key,
month_actual,
month_date,
case mod (to_char (month_date, 'mm'), 6)
When 0 then sum (month_actual)
During)
term_key partition
order of month_date
between the previous month '5' interval and the current line
)
end '6 MONTHS in TOTAL'
from tbl
order of term_key,
month_date
/
TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
---------- ------------ --------- --------------
82 500 NOVEMBER 1ST, 15TH
82 450 1 DECEMBER 15 950
82 405 1 JANUARY 16
82 400 1 FEBRUARY 16
82 450 1ST MARCH 16
82 425 1ST APRIL 16
82 435 1 MAY 16
82 410 2525 1 JUNE 16
82 409 1 JULY 16
82 415 1ST AUGUST 16
82 420 16 - SEP - 01TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
---------- ------------ --------- --------------
82 422 1 OCTOBER 16
82-436 NOVEMBER 1, 16
82 556 2658 1 DECEMBER 16
82 568 1 JANUARY 17
82 624 1 FEBRUARY 1716 selected lines.
SQL >
SY.
-
SQL query for the region of the tree
Hello
I was wondering if someone is able to help me work on a SQL query, to format the data in the table required in a part of the tree... I've never used a tree and I'm fighting to get the right data (if possible).
The data in the table looks like this:
I want to put it in a tree, using level 1 level6 with a final layout that would look like this:
As you can see, the data are formatted in level6 down in the tree, but are filled in the table from level 1. Not all of the columns will be filled, so level2 for anyone 4 (France) is the equivalent of level in the tree like level6 to person 1 (Spain).
This is Apex 4.2.5
Oracle 11.2.0.3.0
Sample data:
CREATE TABLE employees ( employee VARCHAR2(100), level1 VARCHAR2(100), level2 VARCHAR2(100), level3 VARCHAR2(100), level4 VARCHAR2(100), level5 VARCHAR2(100), level6 VARCHAR2(100) ); INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person1','Team One','Recruitment','Human Resources','Fictituous Company','Murcia','Spain'); INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person2','Team Four','Testing','IT','Big Corporate','Hanover','Germany'); INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person3','Big Corporate','Hanover','Germany', null, null, null); INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person4','Brittany','France', null, null, null, null); INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person5','Team Three','Testing','IT','Big Corporate','Hanover','Germany'); INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person6','Public Relations','Government Agency','Brittany','France', null, null);
Added example given.
Hello
Apex-user wrote:
Thanks Frank, this is a good example, I can work with that! Your assumptions are correct.
A question I came, however, is that I have a data segment that comes across poorly formatted so to speak... where only the lower levels (1-2, etc.) have been filled from the bottom up.
An example of this data would be:
- INSERT INTO employees (employee, level 1, 2, level3, level4, level5, level6) VALUES ('Person7', 'One Team', 'Test', null, null, null, null);
As you can see that if you rerun the select, the test team is now duplicated, both at the level of the root in the tree as it should.
You are not sure if the sql can be adjusted to account for this, or if it's too hard?
It is obviously a question of data and I am trying to solve this separately (extracted data from another system out of my control).
Thank you!
Sorry, I'm confused.
You say that my assumptions were correct. What includes supported that "If test ' occurs under 'IT' in a row, then the extent of the 'Testing' occurs, it must be under"IT "? Right after you say that assumptions are correct, you give an example where 'Testing' occurs under 'IT' to a single line, but it is not less 'IT' to another line and where is 'One Team' under 'Testing' in a line, but is 'One Team' under 'Recruitment' in another row.
When a situation like this occurs, how you cope? Whenever you have a problem, please post the exact results you want from the given sample data, and an explanation of how you get these results. If you don't know about what would be the ideal results, or if you are flexible on the exact results, then at least give an example and explain your reasons.
Maybe you want to change the got_parent of subquery like this:
WITH unpivoted_data AS
(
SELECT *.
Employees
UNPIVOT (node_name
FOR lvl (level1 AS 1
level2 AS 2
level3 AS 3
level4 AS 4
level5 AS 5
level6 AS-6
)
)
)
got_parent AS
(
SELECT c.node_name
MIN (p.node_name) AS a parent
Of unpivoted_data c
LEFT OUTER JOIN unpivoted_data p ON p.employee = c.employee
AND p.lvl = c.lvl + 1
GROUP BY c.node_name
)
SELECT LPAD (' ' ')
2 * (LEVEL - 1)
) || Node_name AS entity
OF got_parent
START WITH parent IS NULL
Parent = node_name PRIOR CONNECTION
;
In this way, if 'Test' is current 'IT' in one line, but not under what in another line, whether under would consider the 'IT' request and not to be a root. If 'One Team' sudden 'Testing' in a line, but under "Recruitment" in another line, it will be (arbitrarily) consider it under "recruitment".
-
More than 1 SQL query with checkbox and error invalid number report
Hi all
I have two SQL query reports that each has an apex_item.checkbox and two processes for each report. A report/process works very well. It gives me an error of invalid number.
In addition, another query SQL (editable report) gives me the following error when using the Multi line process, delete.
ORA-06502: PL/SQL: digital or value error: character number conversion
error ORA-06502: PL/SQL: digital or value error: character number conversion
errorOk When I got a report from SQL query (with box and a process) and the query SQL (editable report) everything worked. It stopped working when I added another SQL query report (with box and a process).
A SQL query has the following in my query: apex_item.checkbox(3,email_id,'UNCHECKED') ""
The other SQL query has the following: apex_item.checkbox(2,b.file_id,'UNCHECKED') ""
Any help will be greatly appreciated,
Sylvia
Hi Reema,
I've recreated the region and now it works!
Thank you for this, looking at
Sylvia
-
Hi all
I'm trying to find a solution to this problem
SELECT b.person,
tbl1.program_code,
TO_CHAR (to_date (tbl1.start_date, 'YYYYMMDD'), ' MM/DD/YYYY'),
TO_CHAR (to_date (tbl1.end_date, 'YYYYMMDD'), ' MM/DD/YYYY'),
TBL2.program_code,
TO_CHAR (to_date (TBL2.start_date, 'YYYYMMDD'), ' MM/DD/YYYY')
Person_table p,
(SELECT e.person,
e.program_code,
e.start_date,
e.end_date,
OF e program_table,.
a_program_table has,
WHERE the e.end_date BETWEEN: first_day_year AND: last_day_year
AND a.system_date > to_date (: last_run_date, 'YYYYMMDD')) tbl1.
(SELECT e.person,
e.program_code,
e.start_date,
e.end_date,
OF e program_table,.
a_program_table has,
WHERE the e.start_date BETWEEN: first_day_year AND: last_day_year
AND a.system_date > to_date (: last_run_date, 'YYYYMMDD')) tbl2
WHERE = tbl1.person p.person
AND tbl1.person = tbl2.person
AND to_date (tbl1.end_date, 'YYYYMMDD') < to_date (tbl2.start_date, 'YYYYMMDD')
ORDER BY tbl2.start_date asc, asc tbl1.end_date;
The tables look like this
Program_table
PERSON PROGRAM_CODE START_DATE END_DATE
------ ------------ ---------- ---------
20150115 20150101 17 A1
20150125 20150116 13 A1
20150210 20150126 3 A1
20150220 20150211 16 A1
22991231 20150221 13 A1
A_program_table
PERSON PROGRAM_CODE START_DATE END_DATE SYSTEM_DATE
------ ------------ ---------- --------- -----------
17 20150101 20150115 20150101 A1
13 20150116 20150125 20150116 A1
3 20150126 20150210 20150126 A1
16 20150211 20150220 20150211 A1
13 20150221 22001231 20150221 A1
OUTPUT_RESULT
PERSON PROGRAM_CODE START_DATE END_DATE PROGRAM_CODE START_DATE
------ ------------ ---------- -------- ------------ ----------
A1 3 26/01/2015 10/02/2015 13 21/02/2015 -the unwanted span
A1 3 26/01/2015 10/02/2015 16 02/11/2015
16/02/11/2015-02/20/2015 A1 13 21/02/2015
As you can see here, I'm recording a person of conversion from one program to the other, given that the query has been run since last month. The results I'm capture is for the month of February.
I wanted the transition of the program 3-16 and 16-13, but not from 3 to 13. I need to eliminate the transition from 3 to 13. The reason why is this makes its appearance is due to the line
AND to_date (tbl1.end_date, 'YYYYMMDD') < to_date (tbl2.start_date, 'YYYYMMDD').
I use this because I want the result spans compared dynamically.
I'm looking for change of this request (for example: we can have 10 entries on the table for a month, but have only 9 transitions listed in the final - either).
Note: I would like to have a single query while as noted above, no procedure or query.
Thanks in advance
Hello
Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.
Also post the exact results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
You said that this problem was "creation of the pl/sql query", but you have probably not all PL/SQL; just SQL.
2886750 wrote:
...
AND to_date (tbl1.end_date, 'YYYYMMDD')< to_date="" (tbl2.start_date,="">
Do not store information on dates in the string columns. Use the DATE columns. Then you won't need TO_DATE in conditions like this.
You do a join to match each row in each previous row for the same person. If I understand the problem, you don't want to compare with each previous line, you only want to compare with the last front row. That sound like a job for the analytic LAG function.
Maybe you are looking for
-
Satellite A300 PSAGCE: is it possible for a start of the external CD/DVD drive?
Hello Could someone tell me if it is possible to start the toshiba satellite a300 psagce of cd player external usb? Best regardsMiguel Alves
-
Parental for separated parents
Hello I have recently upgraded to windows 10, and in the order on behalf of my son move to windows 10 family settings, it prompted me to send him an invitation to my 'family' (of which he was already gone when it was Windows 8). However, it does give
-
I try to delete an element froma table 1 d usind the function "remove table". I don't know why, but the output is of the same length as the original with the element table I tried to remove - repplaced with a copy of another element. No one knows why
-
Hi there u clvr g33ks. Wu can help me slve ths prblm? My XP PC clock does not have to be updated; error report is: "the RPC server is unavailable"? I have tried pretty much everything hv what is allocated to me.
-
The analysis of the PDF file cannot be printed
Hello I have a Mac running Mac Os X 10.7.3 I bought a HP officejet PRO 8500 A910. The printer is installed and works very well if one want to print a document or an image. The scanner also works. BUT there is a problem. When I scan a document into my