Poller DB to select records based on the timestamp
Hi all
I want select records from the coloumn timestamp where the timestamp is older than an hour. Is it possible to do this through poller db? I tried but unable to pass the dynamic value (currently - 1 hr)
Thanks in advance!
Eventually create a view based on the timestamp and singled out the dbpoller view.
Tags: Oracle
Similar Questions
-
Select records based on the monthly anniversary date
Hello
I have a table with a field of date_added and I want to select records from monthly birthday of this field.
for example. ID, Date_added
1, DECEMBER 10, 2012
2, 11 NOVEMBER 2012
3, 10 MARCH 2012
4, FEBRUARY 28, 2012
5, 30 DECEMBER 2012
So for January 10, 2013, I would like to return the documents 1 and 3 only
I started watching the extract function, but this little falls down to the records at the end of the month. For example, on 28 February, I also include records where 29, 30 or 31 is the day of date_added. So, in the above table, I won't return documents 4 and 5, but retrieves only returns 4.
Is there a simple function to make the request of birthday this month - have I missed something very obvious? Or I have to write a query to explicitly dates at the end of the month? So far I have not found a reasonable solution!
I use 11g
Thank youuser11259857 wrote:
Hi Al,.No I don't think that there is a flaw. For example, the 30 Jan is not the last day of the month, but is June 30. Thus, on 30 January I want only to interrogate all the dates falling on the 30th - 28 February, after already being interrogated on the 28 Jan. However, on 30 June, I would query the 30th of each month, as well as the 31 January, March, may, July, Aug, Oct, dec. February is a special case, being both shorter and a leap year
Thank you
Richard
Hi Richard,
so, we can assume that your needs are:
If the day is the last day of that month, interview the day of the other months being > = day of the current month.
That is to say:
Jan-30 = query only 30 other months
Jan-31 = query only 31 of the other monthsFeb-28 (non-leap years) = question 28, 29, 30 and 31 other months
29 February (leap year) = query 29,30,31 to other monthsMar-30 = query only 30 other months
Apr-30 = query 30 and 31 other monthsThis hypothesis is correct?
If so, then something like this should work:
WITH mydates(id, date_added) AS ( SELECT 1, TO_DATE('10-DEC-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL SELECT 2, TO_DATE('11-NOV-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL SELECT 3, TO_DATE('10-MAR-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL SELECT 4, TO_DATE('28-FEB-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL SELECT 5, TO_DATE('30-DEC-2012', 'DD-MON-YYYY') FROM DUAL ) SELECT id, date_added FROM mydates WHERE (:input_date = LAST_DAY(:input_date) AND TO_CHAR(:input_date,'DD') <= TO_CHAR(date_added, 'DD')) OR TO_CHAR(:input_date,'DD') = TO_CHAR(date_added, 'DD'); with input_date = 28/02/2013 id date_added 4 28/02/2012 5 30/12/2012
Kind regards.
AlPublished by: Alberto Faenza on 10 January 2013 15:21
Added example -
Select records based on the value
Hello
I have a table with 3 fields,
and I want to choose single route_id for a po_number where the cost is highWITH t1 AS(SELECT 'P1' po_number,'R1' route_id,1900 route_cost FROM dual UNION ALL SELECT 'P1','R2',2300 FROM dual UNION ALL SELECT 'P1','R3',1100 FROM dual UNION ALL SELECT 'P2','R7',1200 FROM dual UNION ALL SELECT 'P2','R8',4500 FROM dual) SELECT * FROM T1 PO_NUMBER ROUTE_ID ROUTE_COST P1 R1 1900 P1 R2 2300 P1 R3 1100 P2 R7 1200 P2 R8 4500
and my output should be
Thank youPO_NUMBER ROUTE_ID ROUTE_COST P1 R2 2300 P2 R8 4500
San
Published by: sandeep9 on April 9, 2011 04:22WITH t1 AS( SELECT 'P1' po_number,'R1' route_id,1900 route_cost FROM dual UNION ALL SELECT 'P1','R2',2300 FROM dual UNION ALL SELECT 'P1','R3',1100 FROM dual UNION ALL SELECT 'P2','R7',1200 FROM dual UNION ALL SELECT 'P2','R8',4500 FROM dual ) SELECT po_number, max(route_id) keep(dense_rank last order by route_cost) route_id, max(route_cost) route_cost FROM T1 GROUP BY po_number / PO RO ROUTE_COST -- -- ---------- P1 R2 2300 P2 R8 4500 SQL>
SY.
-
Rows based on the timestamp column
Hi Experts
I'm trying to get the last 3 records based on the timestamp column. But I am not able to understand where I should start... ?
To make it more clear
I have the following data
I want toid date 1 07/03/09 3:57:55.000000 PM 2 08/03/09 9:23:55.000000 PM 3 05/03/09 7:53:55.000000 PM 4 08/03/09 5:41:55.000000 PM 5 06/03/09 8:50:55.000000 PM
Thanks and greetings2 08/03/09 9:23:55.000000 PM 4 08/03/09 5:41:55.000000 PM 1 07/03/09 3:57:55.000000 PM
Saurabh Sharmaselect * from ( select * from x order by dt desc ) where rownum <= 3
Published by: Alex Nuijten on March 10, 2009 11:31
-
Select data based on the priority of the State
ID PRO_ID PRO_OBJ_ID TASK_ID DEVELOPER_ID STATUS
121243 4940 37506 5250 6532 REJECTED
122063 4940 37506 5250 6532 RELATIVES
138306 4940 37506 5250 6532 ACCEPTED
138307 4940 37506 5250 6532 WIP
Hello
In the table above, I need to select data based on the State, a status which precedes CLOSE or ACCEPTED it should display all status any State which is after CLOSE or ACCEPTED, we do not consider.
In the scenioro above, it should display only the status of first three. After having ACCEPTED, it should not display something
Please suggest me a request how to write.
Thank you
Sudhir.Try:
SQL> with t as ( 2 select 121243 id, 4940 pro_id, 37506 pro_obj_id, 5250 task_id, 6532 developer_id, 'REJECTED' status from dual union all 3 select 122063, 4940, 37506, 5250, 6532, 'CLOSE' from dual union all 4 select 138306, 4940, 37506, 5250, 6532, 'ACCEPTED' from dual union all 5 select 138307, 4940, 37506, 5250, 6532, 'WIP' from dual union all 6 select 138308, 4940, 37506, 5250, 6532, 'ACCEPTED' from dual union all 7 select 138309, 4940, 37506, 5250, 6532, 'REJECTED' from dual union all 8 select 121243, 4940, 37777, 5250, 6532, 'REJECTED' from dual union all 9 select 122063, 4940, 37777, 5250, 6532, 'CLOSE' from dual union all 10 select 138306, 4940, 37777, 5250, 6532, 'ACCEPTED' from dual union all 11 select 138307, 4940, 37777, 5250, 6532, 'WIP' from dual union all 12 select 138308, 4940, 37777, 5250, 6532, 'ACCEPTED' from dual union all 13 select 138309, 4940, 37777, 5250, 6532, 'WIP' from dual 14 ) -- actual query starts here: 15 select t1.id 16 , t1.pro_id 17 , t1.pro_obj_id 18 , t1.task_id 19 , t1.developer_id 20 , t1.status 21 from t t1 22 where id <= (select max(id) 23 from t t2 24 where t2.status in ( 'ACCEPTED', 'CLOSED' ) 25 and t1.pro_id = t2.pro_id 26 and t1.pro_obj_id = t2.pro_obj_id 27 and t1.task_id = t2.task_id 28 and t1.developer_id = developer_id 29 ); ID PRO_ID PRO_OBJ_ID TASK_ID DEVELOPER_ID STATUS ---------- ---------- ---------- ---------- ------------ -------- 121243 4940 37506 5250 6532 REJECTED 122063 4940 37506 5250 6532 CLOSE 138306 4940 37506 5250 6532 ACCEPTED 138307 4940 37506 5250 6532 WIP 138308 4940 37506 5250 6532 ACCEPTED 121243 4940 37777 5250 6532 REJECTED 122063 4940 37777 5250 6532 CLOSE 138306 4940 37777 5250 6532 ACCEPTED 138307 4940 37777 5250 6532 WIP 138308 4940 37777 5250 6532 ACCEPTED 10 rows selected.
If it works then please provide us with some representative sample data again.
-
unique several record based on the date record selection
Hi experts,
I have a table that contains multiple records for unique identification number now, I select the single record that contains the most recent date.
Here is the structure
Name of Type Null
------ ---- ------------
NUMBER OF ID_P
NAME_P VARCHAR2 (12)
DATE_P TIMESTAMP (6)
Reviews
---------------------
1 loosi 22 August 13 01.27.48.000000000 PM
1 hahahaha August 26, 13 01.28.10.000000000 PM
KK 2 22 August 13 01.28.26.000000000 PM
Emmeline 2 26 August 13 01.28.42.000000000 PM
now I have to select below 2 lines how to write select qurie for this?
1 loosi 26 August 13 01.27.48.000000000 PM
Emmeline 2 26 August 13 01.28.42.000000000 PM
Hello
You can use the ROW_NUMBER analytic function.
I don't have a copy of your table, so I'll use scott.emp to illustrate. In scott.emp, there may be several lines for a single job. To display only 1 row per job, hiredate line with the most recent:
WITH got_r_num AS
(
SELECT empno, hiredate-, deptno, job or whatever columns you want
ROW_NUMBER () taken OVER (PARTITION OF work
ORDER BY hiredate DESC
) AS r_num
FROM scott.emp
-WHERE--if you need a filter put it here
)
SELECT *- or the list of all columns except r_num
OF got_r_num
WHERE r_num = 1
;
What results do you want in the case of links? Depending on your needs, you can add expressions of tiebreaker to the analytical ORDER BY clause or the use of RANK instead of ROW_NUMBER.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.
If you change the query at all, post your modified version.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002
-
Selection of records based on the flag
Hi all
I have records as follows:
Program name Effective_Date Valid_Flag
N 10/02/2012 ABCD
N 14/02/2012 ABCD
ABCD 20/02/2012 Y
N 01/03/2012 ABCD
N 10/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
N 26/03/2012 ABCD
N 27/03/2012 ABCD
N 28/03/2012 ABCD
N 29/03/2012 ABCD
ABCD 25/04/2012 Y
I have to write a select statement to keep the first record and then only pull records when the Valid_Flag has changed. The result set should be as below.
Program name Effective_Date Valid_Flag
ABCD 10/02/2012 N - I kept the first record
20/02/2012 ABCD is - Valid_Flag chages to a Y for the first time and so on.
N 01/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
ABCD 25/04/2012 Y
If there is no change in the flag, I don't have to draw from this record. Please help with suggestions of SQL. Thanks for your time and your help.ssk1974 wrote:
Hi allI have records as follows:
Program name Effective_Date Valid_Flag
N 10/02/2012 ABCD
N 14/02/2012 ABCD
ABCD 20/02/2012 Y
N 01/03/2012 ABCD
N 10/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
N 26/03/2012 ABCD
N 27/03/2012 ABCD
N 28/03/2012 ABCD
N 29/03/2012 ABCD
ABCD 25/04/2012 YI have to write a select statement to keep the first record and then only pull records when the Valid_Flag has changed. The result set should be as below.
Program name Effective_Date Valid_Flag
ABCD 10/02/2012 N - I kept the first record
20/02/2012 ABCD is - Valid_Flag chages to a Y for the first time and so on.
N 01/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
ABCD 25/04/2012 YIf there is no change in the flag, I don't have to draw from this record. Please help with suggestions of SQL. Thanks for your time and your help.
In the future, it would be nice if you could provide the sample data as below, I created.
ME_XE?with data as 2 ( 3 select 'ABCD' as col1, to_date('2/10/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 4 select 'ABCD' as col1, to_date('2/14/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 5 select 'ABCD' as col1, to_date('2/20/2012', 'mm/dd/yyyy') as col2, 'Y' as col3 from dual union all 6 select 'ABCD' as col1, to_date('3/01/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 7 select 'ABCD' as col1, to_date('3/10/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 8 select 'ABCD' as col1, to_date('3/14/2012', 'mm/dd/yyyy') as col2, 'Y' as col3 from dual union all 9 select 'ABCD' as col1, to_date('3/25/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 10 select 'ABCD' as col1, to_date('3/26/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 11 select 'ABCD' as col1, to_date('3/27/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 12 select 'ABCD' as col1, to_date('3/28/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 13 select 'ABCD' as col1, to_date('3/29/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 14 select 'ABCD' as col1, to_date('4/25/2012', 'mm/dd/yyyy') as col2, 'Y' as col3 from dual 15 ) 16 select * 17 from 18 ( 19 select 20 col1, col2, col3, 21 lag(col3) over (partition by col1 order by col2 asc) as last_flag 22 from data 23 ) 24 where last_flag != col3 25 or last_flag is null; COL1 COL2 COL LAS ------------ -------------------------- --- --- ABCD 10-FEB-2012 12 00:00 N ABCD 20-FEB-2012 12 00:00 Y N ABCD 01-MAR-2012 12 00:00 N Y ABCD 14-MAR-2012 12 00:00 Y N ABCD 25-MAR-2012 12 00:00 N Y ABCD 25-APR-2012 12 00:00 Y N 6 rows selected. Elapsed: 00:00:00.08 ME_XE?
See you soon,.
-
Delete records based on the foreign keys of oracle 11 g
I have a requirement to remove the records from the tables in the order according to
the existing foreign keys.
I for example, the following tables and the pk, fk constraints:
create table one
(aa number (1),)
descr varchar2 (20));
ALTER table one
Add constraint a_pk key (aa) primary;
create table b
(aa number (1),)
descr varchar2 (20));
ALTER table b
Add constraint b_pk key (aa) primary;
create table c
(aa number (1),)
descr varchar2 (20));
ALTER table c
Add constraint c_pk key (aa) primary;
create table a2
(aa number (2),)
id_aa number (1).
descr varchar2 (20));
ALTER table a2
Add constraint a2_pk key (aa) primary;
ALTER table a2
Add constraint a2_fk foreign key (id_aa)
references a (aa);
create table b2
(aa number (2),)
id_aa number (1).
descr varchar2 (20));
ALTER table b2
Add constraint b2_pk key (aa) primary;
ALTER table b2
Add constraint b2_fk foreign key (id_aa)
references b (aa);
create table z
(aa number (3),)
id_aa number (1).
id_bb number (1).
descr varchar (20));
ALTER table z
Add constraint z_pk key (aa) primary;
ALTER table z
Add constraint z_fk1 foreign key (id_aa)
references a (aa);
ALTER table z
Add constraint z_fk2 foreign key (id_bb)
references b (aa);
So, I want to choose the names of the tables in such an order so as
deleting records will succeed...
I built the following sql query (using the recursive subquery factoring):
[p]
with q (r_constraint_name, table_name, constraint_name, lvl) as
(select table_name, constraint_name, r_constraint_name 1 lvl
from user_constraints one
where a.constraint_type = 'P '.
Union of all the
Select b.table_name b.constraint_name, b.r_constraint_name, q.lvl + 1 lvl
from user_constraints b
Join q
on (q.constraint_name = b.r_constraint_name)
where b.constraint_type = 'R '.
)
Select f.table_name, f.constraint_name, f.r_constraint_name, f.lvl
q f
[/ p]
I want the results as the following list:
Table-name
----------------
B2
A2
Z
A
B
C
The table - B2, A2, Z - (in any order) must first referred in the list
because they are based on the other three tables - A, B, C. Thus, in order to remove the
A, B, C table records the B2, A2, table Z records must be beleted first.
The query I posted above has the problem that it displays tables A2, B2 twice
(1 because they have a pk and 2 because they have fk referring A, B relatively tables).
Is there a solution for this problem?
Note: I use db11g v2
I wrote not all relationships of tables user_constraints (only argument constraint_name = r_constraint_name)
Thank you
SIM
I have a requirement to remove the records from the tables in the order according to
the existing foreign keys.
. . .
The table - B2, A2, Z - (in any order) must first referred in the list
because they are based on the other three tables - A, B, C. Thus, in order to remove the
A, B, C table records the B2, A2, table Z records must be beleted first.
Is there a solution for this problem?
Yes - the 'solution' is to use ON DELETE CASCADE, as appropriate or write a procedure that removes tables in the proper order.
The solution is NOT to try to use dynamic sql statements to do so.
You already know the good parent/child relationships. Simply create a procedure that uses the correct order.
Analyses are necessary in any case to determine the proper order AND press the appropriate values to use to remove the appropriate lines
Your DDL for tables and constraints must be in a version control system
Update the procedure when / if new constraints or tables are added to the application
IMHO, you must use dynamic SQL NOT to try to adjust automatically if a new constraint appears. New constraints should not appear by accident - they appear ONLY as part of a well planned release.
-
Retention of records based on the end of the calendar year
Content using WebCenter 11 g and Records Management, I'm looking for a way to create a rule of provision based on the end of a calendar year. For example, the rule might wait two years after the end of the calendar year in which the content item has been published. Does anyone know how to do this? I'm looking for something that is easy to maintain, but right now my best option is to create a metadata field to end of calendar year and then do a little iDoc script to set point which is archived for each content. I would really like to avoid this if possible. Any ideas?
I think what you're trying to do is to "synchronize on the period start date. It is part of the definition of the trigger.
http://docs.oracle.com/cd/E21764_01/doc.1111/e10640/e01_interface.htm#RMDSG620.
Assuming that the trigger is based on the release date:
-An item is activated in June 30, 2016.
-After the date of recording, wait two years. This makes the eligible trigger on June 30, 2018.
- But you want to wait until the end of 2018 to make available.
-Check the above mentioned framework would force alienation to fire on January 1, 2019, instead of June 30, 2018.
-
Deleting record based on the ID of the main table
Hello
I am trying to remove the news that are published before 2012, but the tables in detail consists the notebook of the child based on the news_id has been. Request certainly simple deletion will not workSQL> desc news Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NOT NULL NUMBER(14) NEWS_DATE TIMESTAMP(0) SL_ID NUMBER(2) HEADING VARCHAR2(3120) DESCRIPTION VARCHAR2(3900) SQL> desc news_location Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) COUNTRY VARCHAR2(32) REGION NUMBER(2) SQL> desc news_product Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) PRODUCT_CATEGORY_ID NOT NULL NUMBER(14) PRODUCT VARCHAR2(27) SQL> desc news_service Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) SERVICE_ID NOT NULL NUMBER(14) SRVIS VARCHAR2(16) SQL> desc news_info Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) SOURCE VARCHAR2(203) ORIGIONAL_NEWS VARCHAR2(3900) HEADING VARCHAR2(3110) SQL> select count(*) from news where TO_CHAR(news_date,'YYYY') < 2012; COUNT(*) ---------- 8759
Please advise and thank you in advanceOnce again, I tell you, do not need ON DELETE CASCADE in the Delete query.
Just use the Delete query like: -.
delete from news where TO_CHAR(news_date,'YYYY') < 2008;
And the child tables are deleted as a result.
-
Select lines based on the State of the same line
Hello
I have the following table structure and lines defind here
http://sqlfiddle.com/#! 3f474/4/3
I want Select if lines
is null, then I need to select rows that have the IS_PAYABLE = 'Y '. IfPRODUCT_NO
is not nullPRODUCT_NO
then IS_PAYABLE will be ' no or IS_PAYABLE will be null.
For example
For PRODUCT_REG HPO_FABRIC, a
NULL if I need select this line only, not the other two rows.PRODUCT_NO
I can do
, but if there are many records with null or not null PRODUCT_NOselect * from SUPPLIER_DETAILS where IS_PAYABLE='Y'
How can I do this using sql?select PRODUCT_REG, PRODUCT_SUPPLIER_CODE, PRODUCT_NO, START_DATE, END_DATE, IS_PAYABLE from ( select PRODUCT_REG, PRODUCT_SUPPLIER_CODE, PRODUCT_NO, START_DATE, END_DATE, IS_PAYABLE, row_number() over (partition by product_reg order by decode(is_payable,'Y',1,'N',2,3), product_no nulls first) rn from SUPPLIER_DETAILS ) where rn = 1 PRODUCT_REG PRODUCT_SUPPLIER_CODE PRODUCT_NO START_DATE END_DATE IS_PAYABLE HPO_FABRIC JP_008 - 08/01/2001 08/31/2001 Y STG_PIL SJ_090 STG-PILLOWS 01/04/2001 01/31/2001 -
Published by: chris227 on 17.09.2012 13:30
-
Need to set the attribute of the current record based on the value of the next record
With the help of forms 6, I have a form that displays the list of folders. There may be multiple records with the same ID, but with different expiration dates. I need set attributes for hilite only the record with the latest expiration date. The current list points of interest reviews of future expiration dates - but we found that, sometimes, the subscription is renewed before the expiration date has been reached, causing two records with the same ID with expiry dates in the future.
I can (and do) sort the records by date of expiry and the identification for the record with the latest expiration date is always the last to this ID, so what I want to do is to check the next record to see whether or not it has a different ID. If the current record is the last expiration date, & must be hilited. Because I might want to hilite the current record, I can't simply navigate to another record, according to the description I found, what makes the next_record builtin. Anyone know how I can check for a value in the next record without making the current record?
Thank you.What I would do:
-Create a DB view based on your table and including the function call DRIVE as a separate column.
-Base that block you on this point of view
-If the block is modifiable, set the DML target for the block to your database table. -
I have a timestamp in a picture and I build metrics on this basis.
If the time stamp is equal to or after 18:00 every day, so, I need to create a column B with a value of 1 and if this isn't a 0
Ex:
Thanks in advance...Column A 12/12/2011 05:34:45 AM 12/1/2011 06:32:45 PM My output would look like: Column A Column B 12/12/2011 05:34:45 AM 0 12/1/2011 06:32:45 PM 1
user517674 wrote:
The solution works for all, except if the timestamp is left saying 17:32 in this case.
Use:
SELECT a , CASE WHEN TO_CHAR (a, 'HH24MISS') < '173200' THEN 0 ELSE 1 END AS b FROM table_x ;
SY.
-
Filter records based on the selection in adf 11.6
Hello
I have page, on the top section af:table displayed and tabs (af:showdetaiItem), in the section displayed below each tab having slumped workflow as a region (each workflow with the table)
After selecting any line on table top, then should filter the corresponding records on table region taskflow I am able to get the selected value to the region through input parameters task flow.
I have question concern, how to run the workflow after the selection of each row in the table? (see communication of the region)
Please suggest good approach, as appropriate
Thank you
you are correct. by passage of parameter is an approach. Another approach is contextual event...
-
Select a record based on the date field MAX
I have the following query that works, but does include all the necessary columns. I need to JOIN the run_events table, which is a child of the runroute table, such that I choose not only the run_code and max event_timestamp, but also the LATITUDE, LONGITUDE columns. Each run_code has many events associated with it.
Any help or pointers would be appreciated!
Thank you
I've included descriptions of output and query table
WITH
ETV as (select run_code
-, LATITUDE, LONGITUDE
max (event_timestamp) TS
of run_events
Run_code group
)
SELECT all THE RR.run_code,
substr(PODDept.POD_NAME,1,10) DEPT,
To_char (ETD ' HH: mi: SS AM') r_ETD,.
To_char (ATD, ' HH: mi: SS AM') r_ATD,.
substr (PODDest.POD_NAME, 1, 10) Dest,
To_char (ETA, "HH: mi: SS AM'") r_ETA,.
To_char (ATA, ' HH: mi: SS AM') r_ATA
-- , VTE. LATITUDE, ETV. LONGITUDE
to_char (VTE. TS, ' dd-mm-yyyy hh: mi: SS AM') TS
OF routerun RR
PADE LEFT JOIN PODDest ON RR. PODEST_CODE = PODDest.POD_ID
LEFT JOIN PADE PODDept ON RR. PODEPT_CODE = PODDept.pod_id
ETV LEFT JOIN ON RR.run_code = VTE.run_code
WHERE ATA IS NULL
ORDER BY RR. ETA, RR. RUN_CODE
/
SQL > @rpt_runroute.sql
RUN_CODE DEPT R_ETD DEST R_ETA R_ATA TS R_ATD
--------------- ---------- --------------- --------------- ------------------ --------------- --------------- ----------------------
2013432247 NORFOLK 23:39:59 CHERRY PT 02:00 07/10/2013 01:00:15
NEW YORK 20:45:03 2013432224 CRESCENT B 06:00 10/07/2013 12:52:28 AM
2013432242 BALTIMORE 22:33:23 SALISBURY 10/07/2013 12:39:28 AM
Descriptions of table
PADE
Name Null? Type
---------------------- -------- --------------------------------------------------
POD_ID NOT NULL NUMBER (10)
POD_LONGITUDE NUMBER (10.6)
POD_LATITUDE NUMBER (10.6)
POD_NAME VARCHAR2 (64)
ROUTERUN
Name Null? Type
---------------------- -------- --------------------------------------------------
RUN_CODE NOT NULL VARCHAR2 (15)
REMARKS VARCHAR2 (1024)
PODEST_CODE NUMBER (10)
PODEPT_CODE NUMBER (10)
ETD DATE
ATD DATE
ETA DATE
ATA DATE
RUN_EVENTS
Name Null? Type
---------------------- -------- --------------------------------------------------
RUN_CODE NOT NULL VARCHAR2 (15)
EVENT_TIMESTAMP NOT NULL DATE
EVENT_CODE NOT NULL VARCHAR2 (6)
LONGITUDE NUMBER (10.6)
LATITUDE NUMBER (10.6)
Hello
One way is to use the MAX function analytical rather than the MAX aggregate, like this:
WITH
ETV as (select run_code
LATITUDE, LONGITUDE
, event_timestamp-* ADDED *.
, max (event_timestamp) OVER (PARTITION BY run_code)-* CHANGED *.
as TS
of run_events
-Group by run_code-* REMOVED *.
)
SELECT all THE RR.run_code,
substr(PODDept.POD_NAME,1,10) DEPT,
To_char (ETD ' HH: mi: SS AM') r_ETD,.
To_char (ATD, ' HH: mi: SS AM') r_ATD,.
substr (PODDest.POD_NAME, 1, 10) Dest,
To_char (ETA, "HH: mi: SS AM'") r_ETA,.
To_char (ATA, ' HH: mi: SS AM') r_ATA - if ATA is NULL, what's the point?
ETV. LATITUDE, ETV. LONGITUDE
to_char (VTE. TS, ' dd-mm-yyyy hh: mi: SS AM') TS
OF routerun RR
PADE LEFT JOIN PODDest ON RR. PODEST_CODE = PODDest.POD_ID
LEFT JOIN PADE PODDept ON RR. PODEPT_CODE = PODDept.pod_id
ETV LEFT JOIN ON RR.run_code = VTE.run_code
AND VTE.event_timestamp = VTE.ts-* ADDED *.
WHERE ATA IS NULL
ORDER BY RR. ETA, RR. RUN_CODE
/
If you would care to post, CREATE TABLE and INSERT statements for some sample data and the results you want from this data, then I could test it.
What happens if there is a tie for the final event_timestamp (i.e. 2 or more lines with the same exct run_code and event_timestamp)? You can use the analytic ROW_NUMBER function instead of MAX.
Maybe you are looking for
-
The two OS - x under macOS Sierra 10.12, all a few minutes my Mac slows down and now Activity Monitor shows at least one and sometimes up to three "Installer" process running - each consume at least 1.5 GB of memory. Of course, these are the indicat
-
IM need SATA XP drivers for Satellite L650 - 11F PSK1JE
HelloMaybe someone has a link for some SATA drivers for my laptop, just can't find them. I want to install Windows XP Home edition, but have no drivers for the SATA controller.What setuo laptop win xp - disk not found, im cannt seteup xp!Please help
-
Hello I am looking for an option as a model in C++ where I create a template control Let's say ring, use it in a VI and call this VI with different rings (rings with different entries). While I tried on my own path, but do not get the result. I hope
-
BlackBerry Q5 unfortunately, Skype has ceased.
I searched the forums for "Unfortunately Skype" and nothing came. If I'm writing this in case someone is facing a similar problem in the future. Skype keep you giving an error message that says: "Unfortunately, Skype stopped? Have you recently upgrad
-
BlackBerry smartphones is the support bluetooth headset Motorola S10 Playbook?
I have a Motorola S10 bluetooth headset. I am able to pair it with the Playbook. But never, it connects to the headset. I see the following message is displayed "no service". Everyone tried to pair it with a bluetooth headset?