Difference between two rows in a table.
Hi allI have a requirement where I need to calculate the difference of a column, but the values are in two rows.
Its exactly like that, I'll have a table where I have stored incidents with their status and their modification dates
example:
Incident_Id: Status: Modified_Date (in seconds from a specific date)
1: 1: 9080890
1: 2: 9080999
1: 3: 9081900
2: 1: 10000900
2: 2: 10001000
2: 3: 10002000
Now there I show the time spent by each incident in each State.
That is to say for the State 1 I need the difference between the date of change of condition 2 and updated the date of status 1 Similarly
2 necessary status the difference between the date of change of condition 3 and updated the status date 2 and so on.
the real result, I need is like that
Incident_Id: Status: Timespent
1: 1: (modified_date (status2) - modified_date (status1))
Please help me to write the query to do this.
Kind regards
Tauceef
Can we assume that the lines are classified according TO the event status ?
This (i.e. an Ordering) is necessary in order to systematically identify consecutive lines.
Please try the analytical function LAG and less to the current value.
Tags: Database
Similar Questions
-
Dynamic calculation of the number of days between two dates in a table
Hello
I'm working on request where I dynamically calculate the number of days between two dates in a table.
The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.
APEX version: 5.0
Hi BO123,
BO123 wrote:
Hello
I'm working on request where I dynamically calculate the number of days between two dates in a table.
The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.
APEX version: 5.0
one of the way to do this by calling ajax on change of end_date.
See the sample code given below to fetch the resulting duration and making the field read only after calculation
Step 1: Change your page
under CSS-> Inline, put the code below
.row_item_disabled { cursor: default; opacity: 0.5; filter: alpha(opacity=50); pointer-events: none; }
Step 2: Create on demand Ajax process I say CALC_DURATION
Please check Procces Ajax, see line 6.7 How to assign a value to the variable sent by ajax call
Declare p_start_date date; p_end_date date; p_duration number; Begin p_start_date := to_date(apex_application.g_x01); p_end_date := to_date(apex_application.g_x02); --do your calculation and assign the output to the variable p_duration select p_end_date - p_start_date into p_duration from dual; -- return calculated duration sys.htp.p(p_duration); End;
Step 3: Create the javascript function
Change your page-> the function and the declaration of the Global Variable-> put the javascript function
You must extract the rowid in the first place, for which you want to set the time, see line 2
assuming f06, f07 and f08 is the id of the start date, and end date columns respectively, and duration
See no line no 8 how set the value returned by the process of ajax at the duration column
Replace your column to the respective column identifiers in the code below
function f_calulate_duration(pThis) { var row_id = pThis.id.substr(4); var start_date = $('#f06_'+row_id).val(); apex.server.process ( "CALC_DURATION", { x01: start_date,x02: $(pThis).val() }, { success: function( pData ) { // set duration to duration column $('#f08_'+row_id).val(pData); // disable duration column $("#f08_" + row_id).attr("readonly", true).addClass('row_item_disabled'); } }); }
Step 4: choose the end date call the javascript function
Go to report attributes-> edit your Date column end-> column-> Attrbiutes element attributes-> put the code below
onchange="javascript:f_calulate_duration(this);"
hope this helps you,
Kind regards
Jitendra
-
Exact differences between two images
I need to be able to tell the difference between two images of a pastel artwork.
The first image is of the piece, to be hung on a wall or placed on a table.
The second is a photo of the piece after it has been moved, shaken or vibrated during which time particles were moved.
I tried superimposing the two images and see the difference between the layers. The images never seem to perfectly align along the lines of reference drawn in ink on the piece, and I do not understand the presentation of grayscale of the layer mode of difference. I would like to know if anyone has any photographic photoshopic, or insightful ideas on how to capture this specific detail of change. Another big challenge is now the images themselves to the exact distance and exposure to the room at the before and after photos, especially if they were taken in two different places on different dates.
Best I can think of is to load into Photoshop layers >, select the two layers and go Edit > auto alignment of layers. Then to the blending mode of the layer from the top to the difference.
You can test so that you know what to expect by opening an image and copy the layer of BG and setting the blending mode of the layer copied the difference. It will show as a pure black. Now make tiny changes to the upper layer.
-
Difference between two data aquistion
Hello
I got a data aquistion system that is supposed to keep data acquisition selection until the difference between two points a lot. For example, I get voltage (mv) as 2.31, 2.32, 2.34. 2.33 2.32, 2.33 2.32. the data up to a point, say 0.1V higher or lower than the first. Thewhole procss stop. Thank you for your suggestions.
Try this... (Labview 8.2)
-
difference between two dates in the year/month/day in Obiee
Hi gurus,
I know this question have been asked and answered several times but I have a requirement that is a little different, then the previous ones.
I want to calculate the difference between two dates in OBIEE10g in year/month/day format similar to the below SQL output
SQL > select end_date, start_date,
trunc (months_between (end_date, start_date) / 12) years.
months of mod (trunc (months_between (end_date, start_date)), 12).
End_date - add_months (start_date, trunc (months_between (end_date, start_date))) days
t
Thanks in advance
SK
Search for this
"TIMESTAMPDIFF IN THE FORM OF MTHS # YEARS."
or else
To get the current mandate of employees since the date of hiring in the form of # years # mths or # year (s) # month (s)
Concat (concat (cast (TIMESTAMPDIFF (SQL_TSI_Month, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) / 12 as char),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Month (s)'))
Concat (concat (CAST (TIMESTAMPDIFF (SQL_TSI_YEAR, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) as CHAR),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Mth (s)'))
-
difference between two timestamps
Hi gurus,
I have a procedure which has 2 input parameters of type timestamp. I need to find the difference between these two stamps and be converted to a timestamp and return. Help, please
Diifernce between two timestamps is interval. You can not convert the difference between two timestamp timestamp and it makes no sense. What you expect:
25/06/2014 11:25:37.524000 - 13:07:22.987654 20/06/2014
SY.
-
Cannot get rid of the gaps between the rows in the table with the basic HTML in DW cc 2015
Hi gang
I haven't used html in ages and doing something basic without css... but for some reason any I get these gaps between the rows in the table, no cause I do.
what I am doing wrong?
< ! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 / / IN" "http://www.w3.org/TR/html4/strict.dtd" > ""
< html >
< head >
< meta http-equiv = "Content-Type" content = text/html"; Charset = UTF-8 ">"
< title > Untitled Document < /title >
< / head >
< body >
< table width = "560" >
< /table >
< table width = "560" border = "0" align = "center" cellpadding = "0" cellspacing = "0" >
< tbody >
< b >
< td colspan = "3" > < img src = "images/AAA - ADE_01.jpg" width = "560" > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_02.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_03.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_04.jpg" height = "267" / > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_05.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_06.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_07.jpg" height = "267" / > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_05.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_06.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_07.jpg" height = "267" / > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_08.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_09.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_10.jpg" height = "267" / > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_11.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_12.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_13.jpg" height = "267" / > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_14.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_15.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_16.jpg" height = "267" / > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_17.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_18.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_19.jpg" height = "267" / > < table >
< b >
< td width = "209" > < img src = "images/AAA - ADE_20.jpg" height = "267" / > < table >
< td width = "158" > < img src = "images/AAA - ADE_21.jpg" height = "267" / > < table >
< td width = "193" > < img src = "images/AAA - ADE_22.jpg" height = "267" / > < table >
< /tr >
< / tbody >
< /table >
< / body >
< / html >
Add this in the
section of your pagetable {
border-collapse: collapse;
}
img {
vertical-align: middle;
}
-
How do the time difference between two dates?
Hi all
I use this query to get the time difference between two dates.
Select to_timestamp ('2012-10-03 12:00 ',' YYYY-MM-DD hh)-to_timestamp ('2012-10-03 11:00 ',' YYYY-MM-DD hh) as double diff;
but do not get the correct result.
Thank youLeft KEY... Left Padding of tanks.
-
I am building a working method in LiveCycle, and I want to track how long the procedure takes. To do this, I have two time fields, and then a third time field to find the difference between two time fields. Looking at other posts to discussion, I could find a Javascript code that was part of what I wanted, but I can't get the third time field to display in the format I want. I tried to change the habits of the fields and that did not work. Could someone offer some advice on how to change the format or help me with the code? I couldn't figure to attach the actual file, but I have attached a picture of the PDF file and the Javascript code I used. If you look at the TimeIn (hh: mm) and time (hh: mm) areas (on the photo, I have attached), you will notice that the TotalTime comes out like HMM, and I want that it out as hh: mm.
Any help would be greatly appreciated!
Thank you
this.rawValue = (totalHrs > 9? String (totalHrs): '0' + String (totalHrs)) + ':' + (totalMins > 9? String (totalMins): '0' + String (totalMins));
-
What is the difference between associative arrays and nested tables?
Hello
What is the difference between associative arrays and nested tables?
nested tables cannot be indexed by other than pls_integer and unlike nested tables table associative cananot be declared at the schema level.
is there any other difference set apart from the diff above 2?user13710379 wrote:
What is the difference between associative arrays and nested tables?Name-value pairs (associative) against a list of values (table standard/nested table).
nested tables cannot be indexed by other than pls_integer
They are not "indexed" the way in which an associative array is indexed. A standard table is referenced by the position of the cell in the table. This position is essentially the offset of the memory of the cell from the start address of the table.
Can not solve a cell in an associative array directly via a memory offset index. You place a cell reference value it by his 'name' (a search in the linked list/hash table).
The following example shows the difference between the pairs of name / value and a list of core values.
SQL> declare 2 --// associative arrays are NAME-VALUE pairs 3 type TArr1 is table of varchar2(10) index by pls_integer; 4 type TArr2 is table of varchar2(10) index by varchar2(10); 5 6 arr1 TArr1; 7 arr2 TArr2; 8 begin 9 arr1(100) := '1st entry'; 10 arr1(1) := '2nd entry'; 11 arr1(5) := '3rd entry'; 12 13 arr2('john') := 'New York'; 14 arr2('jane') := 'Paris'; 15 arr2('jack') := 'London'; 16 17 end; 18 / PL/SQL procedure successfully completed. SQL> SQL> SQL> declare 2 --// standard arrays are lists 3 type TArr3 is table of varchar2(10); 4 type TArr4 is table of number; 5 6 arr3 TArr3; 7 arr4 TArr4; 8 begin 9 arr3 := new TArr3( '1st entry', '2nd entry', '3rd entry' ); 10 11 arr4 := new TArr4( 100, 1, 5 ); 12 end; 13 / PL/SQL procedure successfully completed. SQL>
-
How to find the difference between two dates in the presentation layer
Hi gurus,
Hello to everyone. Today, I came with the new requirement.
I need to know the difference between a date and the current date in the formula column application presentation layer.by.
Thank you and best regards,
PratesHi Navin,
TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".
If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...
hope you understand...
Award points and to close the debate, if your question is answered.
See you soon,.
Aravind -
Find the difference between two date and time
Hi friends,
I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."
select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed from eval.EVAL_RUNTIME_DETAILS where trunc(start_date) = trunc(sysdate) order by sql_step_num;
You try to get the feel between two char strings.
And more difference between two dates gives a NUMBER of days.
Try this:select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed from eval.EVAL_RUNTIME_DETAILS where trunc(start_date) = trunc(sysdate) order by sql_step_num;
-
The most elegant way to get the difference between two tables - not least!
Hello
Simplified example of what I'm trying to achieve - I have two tables ORIGINAL and REVISED.
My aim is to compare the two, such as; -
When there is data in the two tables I get the difference between the Budget column, and if there is no difference, so I don't want no lines.
When data exists in the ORIGINAL, but not in review, I want to the inverse of the current value of the Budget column.
Where the data exist in REVISED I want the REVISED value.
I can see how I can do this, see below, but is there a more elegant solution?
Data for the ORIGINAL table
Data for the REVISED tableselect '801040' entity, '2186' expense_type, 234000 budget from dual union all select '801040' entity, '3001' expense_type, 1000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P135' expense_type, 43000 budget from dual
Desired outputselect '801040' entity, '2186' expense_type, 235000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P139' expense_type, 56000 budget from dual
ENTITY EXPENSE_TYPE DIFFERENCE
------ ------------ ----------
801040 2186 1000
801040 3001-1000
801040 P135-43000
801040 P139 56000
5 selected lines.
Code current to achieve this, is there a better way?
Thanks a lot for your comments,.select original.entity , original.expense_type , (nvl(revised.budget,0) - original.budget) as difference from original , revised where original.entity = revised.entity(+) and original.expense_type = revised.expense_type(+) and (nvl(revised.budget,0) - original.budget) != 0 union all select revised.entity , revised.expense_type , revised.budget as difference from revised where not exists (select 'x' from original where original.entity = revised.entity and original.expense_type = revised.expense_type) and revised.budget != 0
Robert.
Published by: Robert Angel on January 17, 2012 03:31 to change is not equal to! = - Thanks for the heads upSQL> with original 2 as 3 ( 4 select '801040' entity, '2186' expense_type, 234000 budget 5 from dual 6 union all 7 select '801040' entity, '3001' expense_type, 1000 budget 8 from dual 9 union all 10 select '801040' entity, 'P132' expense_type, 34000 budget 11 from dual 12 union all 13 select '801040' entity, 'P135' expense_type, 43000 budget 14 from dual 15 ) 16 , revised 17 as 18 ( 19 select '801040' entity, '2186' expense_type, 235000 budget 20 from dual 21 union all 22 select '801040' entity, 'P132' expense_type, 34000 budget 23 from dual 24 union all 25 select '801040' entity, 'P139' expense_type, 56000 budget 26 from dual 27 ) 28 select * 29 from ( 30 select nvl(o.entity, r.entity) entity, 31 nvl(o.expense_type, r.expense_type) expense_type, 32 nvl(r.budget,0) - nvl(o.budget,0) budget 33 from original o 34 full join revised r 35 on o.entity = r.entity 36 and o.expense_type = r.expense_type 37 ) 38 where budget <> 0 39 / ENTITY EXPE BUDGET ------ ---- ---------- 801040 2186 1000 801040 P135 -43000 801040 3001 -1000 801040 P139 56000 SQL>
-
Difference between two tables (ORA-01722)
I am trying to get the difference of two tables on two databases.
Walker I run the script below, it gives me a result that is not accurate.
Select name, creation_time of v$datafile@REMOTE_database.com
However, when I run this script, I get an accurate count of the difference. How can I list the exact number instead of only to count the difference? Want lists all five name missing on table 2.
2 LESS THAN
3 select name, creation_time from v$ datafile;
I get 14 ranks of foregoing.
SQL > SELECT a.cnt - b.cnt
> count 2 (name) select cnt (of v$datafile@REMOTE_database.com) a, b3 (select count (name) NTC v$ datafile);
edited by: Albert Zaza on July 19, 2010 11:19
A.CNT - B. CNT
-----------
5have you tried:
select trim(upper(name)) from v$datafile@REMOTE_database.com MINUS select trim(upper(name)) from v$datafile;
-
Difference between two statement.
I use 11.2.0.3 oracle version, and when I am running below pieces of code and expect similar results.
Below is the variable declare package level as below.
TYPE mycur IS REF CURSOR;
Now mentioned below is my procedure inside the package. My question is, I want to understand the difference between the following two statement in the same procedure. as as statement: 1 give me several records to pk1, where as statement: 2 gives me the good result which is recorded under the outlet of the slider back.
Statement: 1
PROCEDURE p1 (pk1 in NUMBER,
ret_cursor ON mycur)
AS
BEGIN
Open Select ret_cursor *.
A,.
b,
WHERE a.id = b.id
AND (a.c1 = b.c1
GOLD a.c2 = b.c2)
AND a.c3 = pk1;
END;
/
Statement: 2
PROCEDURE p1 (pk1 in NUMBER,
ret_cursor ON mycur)
AS
V_QUERY VARCHAR2 (4000);
BEGIN
V_QUERY: =.
"SELECT."
A,.
b,
WHERE a.id = b.id
AND (a.c1 = b.c1
GOLD a.c2 = b.c2)
AND a.c3 = ' | PK1;
Ret_cursor OPEN for V_QUERY;
END;actually my mistake, I just the reason behind the question. I had published the name of the table variable / by their and are different than real.
So the question was naming convention given by the developers, the name of the input variable looked exactly like that of the name of the column, it's why he estimated at something like 'and (1 = 1)'.The input variable name has been 'c3' as column name 'a' causing problem.
a.C3 = c3
Maybe you are looking for
-
How do you get the browser recognizes the updates of the subject: configuration config updates
-
Satellite R630 - monitor problem
I have a SATELLITE R630-13R. When I start my computer the systems sound works but the display to load the toshiba and windows splash pages, then remains empty. If I open in safe mode, the light is very good. When I attach an external monitor, I can s
-
Not able to make updates. ERROR 80244019. How can I fix it?
-
Hello I am a newbie here so if I do noob errors please forgive me. I have the XPS 8500 with 32 GB msata mb disk cache. Win 7 is the original OS. My HARD drive is dead and when I went to to replace I couldn't get Win7 to install. The only way that fin
-
How can I change the default action of record?
My laptop with Windows vista has curently explores as the default action (because it does not open in a new window which is my chosen prefrence) and opened as the next option. How can I change the default action to open?