Help to write query to get records from specified time TO specified time?

I have a table which has large data and the table is updated every min,
Suppose the Table comp(timeid date,sessions varchar2,sid varchar2)
Here time needs to be checked
So now i have to write a query which displays records that have been in the table
for every 5 mins
default timeframe is sysdate-5 then the lower and upper bound is multiple of 5 i.e
Suppose now Time and sysdate: 12-sep-2007 1:22:00pm
From sysdate: 12-sep-2007 1:15:01pm TO sysdate: 12-sep-2007 1:20:00pm
So i need a query to get the records from 1:15:01pm to 1:20pm.
Message was edited by:
user594721

Explanation is not clear.Please give sample data and expected o/p.
If you need the data of previous five minutes, do like this...
SQL> select id, to_char(time,'dd/mm/yyyy hh:mi:ss') time
  2  from test;
        ID TIME
         1 13/09/2007 10:29:55
         1 13/09/2007 10:29:22
         1 13/09/2007 10:20:28
SQL> select id, to_char(time,'dd/mm/yyyy hh:mi:ss') time,
  2             to_char(sysdate,'dd/mm/yyyy hh:mi:ss') current_time
  3  from test
  4  where time between (sysdate - (5/24/60)) and sysdate;
        ID TIME                CURRENT_TIME
         1 13/09/2007 10:29:55 13/09/2007 10:32:45
         1 13/09/2007 10:29:22 13/09/2007 10:32:45                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Query  for getting records  max  reported  timestamp and 2nd max report

    query for getting records in between
    max reported timestamp and 2nd max reported timestamp
    HERE IS ALL RESULT SET
    TIME DOMAIN
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    QUERY RESULT TO COME
    TIME DOMAIN
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    Message was edited by:
    user517983

    Hi,
    can we write query like this.
    1 select pd_user,PD_REPORTED_TIMESTAMP
    2 from sp_process_detail_current spdc
    3 where host_id='DSCP02469'and pd_user='TOMCAT'
    4 and exists(
    5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
    6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
    SQL> /
    PD_USER PD_REPORTED_TIMESTAM
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45

  • Sql query to get numbers from 0 to 99

    How can we write an sql query to get values from 0 to 99 ... this shouldn't be coming from any table

    Bawer wrote:
    Result: (quickly replied by oracle)
    SQL-Error: ORA-30009 (Not enough memory for connect by - 1GB reserved for oracle on VirtualBox)Oracle version? Takes about 8 seconds on my:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Elapsed: 00:00:00.14
    SQL> select count(*) from (
      2  SELECT LEVEL - 1
      3  FROM DUAL
      4  CONNECT BY LEVEL <= 10000000
      5  )
      6  /
      COUNT(*)
      10000000
    Elapsed: 00:00:07.76
    SQL> SY.

  • SQL query to fetch records  from  26 onwards

    Want to know SQL query to fetch records from 26 onwards.

    See the fifth entry on the FAQ page:
    Re: How to attach a java bean in forms6i

  • OSLC Query to get requirements from a RequirementCollection on DOORS NG

    Hi,
    I'm using DOORS NG (V5.0.2) and I'm trying to get requirements referenced by a RequirementCollection using OSLC.
    I tried the query given on:
    https://jazz.net/library/article/1197
    which is:
    &oslc.prefix=rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=*&oslc.where=rdf:type=<http://open-services.net/ns/rm%23Requirement>
    But this query only returns the RequirementCollection itself.
    So, is the query correct?

    Hello Jim,
    In fact, as you say, that query returns all requirements on a project. I was wrong with the query that I posted and the correct one is the query that you posted, i.e.:
    &oslc.prefix=oslc_rm=<http://open-services.net/ns/rm%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=oslc_rm:uses&oslc.where=dcterms:identifier=1
    However, this query only returns the RequirementCollection whose identifier is 1 and it does not return its requirements.
    The solution that I found and it was supported by Jazz forum (https://jazz.net/forum/questions/200343/oslc-query-for-getting-requirements-from-a-requirement-collection) is to get the RequirementCollection and using the "uses" attributes (links to the associated requirements), which contain the requirement URL, we access to requirement info. by using REST commands.
    I do not have better answer than this one. If someone has a better idea, I would appreciate.
    Cordially,
    Carlos

  • Need help in SQL query to get only distinct records

    Hi all.
    I am new to oracle SQL and i want to write a query to get only distinct values from 2 tables.
    for example i hade 2 tables table1(employee_id,employee_no,grade) and another table2 with same structure.
    for example data in table1 is
    Employeeid employeeno Grade
    1 101 A
    1 101 B
    1 101 E
    1 101 D
    and data in table 2 is
    Employeeid employeeno Grade
    1 101 A
    1 101 B
    1 101 E
    i want to display only the fourth row like the data that doesnt exist in table2 i,e (1 101 D)
    I had too much records in both tables and i jst want to see the records that is in table 1 not in table 2 only.
    employeeid and employeeno are the same in both tables
    I hope u understand my query. I user left outer join and right outer join bt it displays all the results that and matching and unmatching. I want jst unmatched records.
    Any help is highly Appreciated.
    Thanx in Advance.
    I am using oracle 10G on windows

    Try MINUS:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries004.htm#i2054381
    SQL> -- generating sample data:
    SQL> with t1 as (
      2  select 1 employeeid, 101 employeeno, 'A' grade from dual union
      3  select 1, 101, 'B' from dual union
      4  select 1, 101, 'E' from dual union
      5  select 1, 101, 'D' from dual
      6  )
      7  ,  t2 as (
      8  select 1 employeeid, 101 employeeno, 'A' grade from dual union
      9  select 1, 101, 'B' from dual union
    10  select 1, 101, 'E' from dual
    11  )
    12  --
    13  -- actual query:
    14  --
    15  select employeeid
    16  ,      employeeno
    17  ,      grade
    18  from   t1
    19  minus
    20  select employeeid
    21  ,      employeeno
    22  ,      grade
    23  from   t2;
    EMPLOYEEID EMPLOYEENO G
             1        101 D
    1 row selected.

  • Single Query for getting total no of records N getting records from a selected range

    Hi,
    Got the below query:
    SELECT a.*, rowid FROM (SELECT name, postcode FROM Tbl ORDER BY name asc)a WHERE ROWNUM <=30
    MINUS
    SELECT b.*, rowid FROM (SELECT name, postcode FROM Tbl ORDER BY name asc) b WHERE ROWNUM <= 10
    Though I got the results right, I also want to know the total no of records from "SELECT name, postcode FROM Tbl ORDER BY name asc". Does anyone knows how to do it in a single query?
    Thanks.

    hi Carol
    The following output may help you.
    SQL> l
    1 select * from emp where (rowid,0) in (select rowid,mod(rownum,10)-rownum from emp)
    2 minus
    3* select * from emp where (rowid,0) in (select rowid,mod(rownum,6)-rownum from emp)
    SQL> /
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7839 KING PRESIDENT 17-NOV-81 5000 10
    7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
    7876 ADAMS CLERK 7788 12-JAN-83 1100 20
    7900 JAMES CLERK 7698 03-DEC-81 950 30
    The above query fetches the 6,7,8,9th records only.
    Well my suggestion would be not to use ROWNUM directly in where clause since it changes dynamically. it is not a fixed value. for example pls see the result.
    SQL> select rownum,empno,ename,sal,job from emp where sal > 3000;
    ROWNUM EMPNO ENAME SAL JOB
    1 7839 KING 5000 PRESIDENT
    SQL> select rownum,empno,ename,sal,job from emp where sal > 1000;
    ROWNUM EMPNO ENAME SAL JOB
    1 7566 JONES 2975 MANAGER
    2 7654 MARTIN 1250 SALESMAN
    3 7698 BLAKE 2850 MANAGER
    4 7782 CLARK 2450 MANAGER
    5 7788 SCOTT 3000 ANALYST
    6 7839 KING 5000 PRESIDENT
    7 7844 TURNER 1500 SALESMAN
    8 7876 ADAMS 1100 CLERK
    9 7902 FORD 3000 ANALYST
    10 7934 MILLER 1300 CLERK
    10 rows selected.
    SQL> select * from emp where rownum = 1;
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7566 JONES MANAGER 7839 02-APR-81 2975 20
    The record of employee KING is getting the rownum differently.
    My understanding (out of my little knowledge) is the rownum values are assigned to the records only after the records are read physically and after applying the conditions(without rownum). Then the row numbers (rownum) is assigned to the records. Hence the rownum is not constant to a record since it is a dynamic value.
    Well i would like to know the suggestions of the ORACLE EXPERTS here in the discussion forum.
    If my finding is correct then OK if not Pls excuse me and pls give the correct solution
    Regards
    Prakash Eranki
    [email protected]

  • Help needed writing trigger for deleting records from multipul tables

    i am trying to write a trigger which would help me delete the record from 3 different tables
    lets say i have table a , b and c
    i an trying to write a trigger which would help me delete the same record from table a and c.
    drop trigger az_zzz_trigger;
    create trigger az_zzz_trigger
    before INSERT or UPDATE or DELETE ON az_employ
    FOR EACH ROW
    BEGIN
    IF DELETING then
    delete from za_payroll
    delete from az_salary_audit
    end if;
    end;
    while executing this trigger all data of table za_payroll is delete.
    what should i do so that only the record which i delete from az_employ gets deleted from az_payroll and az_salary_audit

    872959 wrote:
    i am trying to write a trigger which would help me delete the record from 3 different tables
    lets say i have table a , b and c
    i an trying to write a trigger which would help me delete the same record from table a and c.
    drop trigger az_zzz_trigger;
    create trigger az_zzz_trigger
    before INSERT or UPDATE or DELETE ON az_employ
    FOR EACH ROW
    BEGIN
    IF DELETING then
    delete from za_payroll
    delete from az_salary_audit
    end if;
    end;
    while executing this trigger all data of table za_payroll is delete.
    what should i do so that only the record which i delete from az_employ gets deleted from az_payroll and az_salary_auditutilize appropriate WHERE clause

  • How do I query a single record from a database?

    I need to retrieve a record from a specific table within a .mdb file using it's name or primary key to search.
    I have the database connectivity toolkit(LV7.1) and have not been able to figure this out.
    Any help would be greatly appreciated.
    Jim

    Bdougr,
    Thanks for the reply, but it's a little over my head.
    Maybe I should give some more info. We store test parameters in a MSAccess database.
    Using LabView 7.1, I would like to retrieve a "record" or row based on a primary key (our part#)from a .mdb file and then use that data as my test parameters, I do not want to use the row# or record#. The database contains several tables so I also need to get to the specific table.
    I have figured out how to get a "feild" or the hole thing but I don't know how to return just one specific row.
    I have tried Select data, Fetch, Fetch all and Execute query VIs without success. Would "Execute query" be the way to do it? If so, what would be the correct SQL syntax to retrieve a record base on its primary key?
    Jim

  • QUERY - No Duplicate records from 2nd table ???

    Hi Experts,
    I really need help with this. I have 2 tables A and B. See below
    <b>A -
         B</b>
    X -
         XB1
    XB2
    XB3
    Y----
    YB
    Z----
    ZB
    I select a record from A and get its record from B and give it on the output. For entry X I have 3 records in Table B. I want the output to give only 1 record from B for X. It can be any record. How can this be achieved in Query ?
    Is there a special Join ? or can this be achieved by coding in Query ? If so how ?
    I really appreciate your help.
    Thanks !!

    First get the data from table A.
    select * from table (A) into table i_a.
    loop at i_a.
    select single * from table B into table i_b.
    move b reord to final internal table
    append final internal table.
    endloop.

  • HELP PLEASE!!! TROUBLE RECORDING FROM DVR TO DVD

    I have everthing set up correctly.  The problem is that at different points in the recording, television feedback appears on the recording!  So whatever is on television at the time is getting recorded.
    Please help me figure this out!
    Thanks.

    I figured it out, with help from some chat technician.  I had to be on L1 and was not.
    Thanks anyway.

  • What to write query to get know if a checkbox is checked

    hello,
    I have created a checkbox with name Entertainment containing static values Movie,Play,music.
    Now i have to write query to check which value of checkbox is checked ,means play or movie or music.
    According to that i have to mail a particular link to a user.
    I have seen in how to (checkbox help) but not getting it.
    please anyone can help me out.

    HI marc,
    I think so u are not able to get my problem,i will explain it in detail.
    I have a table USERINFO which has variables of type varchar2,these variable are used as a checkbox on page name 'ENTER INFORMATION',these checkbox have some static values,every time a user checks checkbox values it get stored in database,suppose there is a checkbox name sport with static values cricket,football,now if any user select cricket this value get stored in database with username ,mailid.
    Now i have a page on this i want to give user facility to enter name of checkbox to create and its corresponding static values,and these checkbox should get display on page 'ENTER INFORMATION'and a variable of type varchar2() with checkbox name should get create in tableUSERINFO .
    now can u suggest me how can i achieve this.

  • Single query to get data from different databases

    i need to capture certain fields from certain tables in database 1 and certain fields from certain tables in database 2 into one file using a single SQL statement.
    i tried searching on the net
    i found that dblinks can help
    but iam not sure if ill be able to create dblinks in my situation which is:
    i need to get data from oracle to be copied to mysql
    this is not a replication acitivity, but i need certain fields from one database and certain from the other
    so what iwas thinking is, if i use an sql query to get all the fields (i need around 40) from the different oracle databases and create a singlefile with one insert per select, i can then read that file into mysql
    instead of creating multiple sql queries for each table and creating separate files and eventually separate tables in mysql.
    can anyone help me here?
    or maybe suggest another approach.
    thanks

    Hi,
    I think dblink is the only option available to get data from different databases. It will work for your case too.
    CREATE DATABASE LINK db_link CONNECT TO user_name IDENTIFIED BY  password USING 'instance_name'you must have the system privilege 'create database link' to create db links. This way you can get the required data and put it in a table in oracle. But i dont know how to put this data from oracle table to Mysql.
    HTH
    Muneer

  • Query to get records between a range...............

    Hi,
    Is there any way in oracle to get records between the records 20-30.
    As far as i know in oracle you can put where rownum < (some integer)
    But is it possible to getsomething between the records 20-30
    Thanks

    Is there any way in oracle to get records between the
    records 20-30.No you can't do it.
    The reason why it's not possible is because oracle has no internal ordering of the records.
    http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
    How ROWNUM Works
    ROWNUM is a pseudocolumn (not a real column) that is available in a query. ROWNUM will be assigned the numbers 1, 2, 3, 4, ... N, where N is the number of rows in the set ROWNUM is used with. A ROWNUM value is not assigned permanently to a row (this is a common misconception). A row in a table does not have a number; you cannot ask for row 5 from a table—there is no such thing.

  • Query to get details from Maintenance plans

    Hi All,
    Could some one please let me know, if there is any way to check whether
    all  databases option is selected under the maintenance plan other than using GUI. Below is the print screen for reference.
    Maintenance plan includes rebuild Index, checkdb and  update statistics steps, I have to check whether the All databases option is selected for each individual task.
    I have a requirement wherein, I have to check this thing on around 5000 servers.
    It would be great if someone lets me know the script to check this setting, so that it will save my time.
    I have used below queries and tables to get the data, but they don't have the information which i'm looking for
     sysdbmaintplan_databases
    Contains one row for each database that has an associated upgraded database maintenance plan.
    sysdbmaintplan_history
        Contains one row for each upgraded database maintenance plan action performed.
    sysdbmaintplan_jobs
        Contains one row for each upgraded database maintenance plan job.
    sysdbmaintplans
        Contains one row for each upgraded database maintenance plan
        select * from sysdbmaintplan_jobs
        SELECT name,subplan_name,subplan_description
        FROM msdb.dbo.sysmaintplan_plans AS s
        INNER JOIN msdb.dbo.sysmaintplan_subplans AS sp ON sp.plan_id=s.id
        Order by name,subplan_name
     SELECT s.name AS MaintenancePlanName,
    sp.subplan_name AS SubplanName,
    subplan_description AS SubplanDescription,
    sj.name AS JobName,
    sj.enabled AS JobStatus,
    ss.name AS ScheduleName
    FROM msdb.dbo.sysmaintplan_plans AS s
    LEFT JOIN msdb.dbo.sysmaintplan_subplans AS sp ON sp.plan_id = s.id
    LEFT JOIN msdb.dbo.sysjobs AS sj ON sj.job_id = sp.job_id
    LEFT JOIN msdb.dbo.sysschedules AS ss ON sp.schedule_id = ss.schedule_id
    ORDER BY s.name,
    sp.subplan_name
    Thanks in Advance.
    Regards, Kranthi

    On a different note,  i think you can script the maintenance plan - ssis package and then insert into sysssiscatalog table and i think this will create the ssis - maintenance plan on the server. not sure ..this is just thought.... they can be compatibility
    issue.
    also, you can use the history - maintenance plans to get the data you need. but the caveat is the maintenance plan should have and history should exist and 'extended log  information' must be checked on the plan. this can be done - checking a text box
     in the plan properties.
    try this query.. i used top 1 ..so, you can try... if all databases are used in the plan..it will just show all  but if only some are used, i split that into multiple rows,(you might not need this)..there are some many other combinations possible,,
    such selecting on some tables etc...  you can query all that information from history tables, 
    try this query 
    use msdb
    go
    select top 1 @@SERVERNAME [servername],case when d.Succeeded=1 then 'Success' when d.succeeded=0 then 'Failed' End as Result,
    name,b.subplan_name,D.line1,D.line2,replace(D.line3,'Databases: ','') as [DBs],D.line4,D.line5,D.start_time,D.end_time,D.command,d.Succeeded
    into #test
    from sysmaintplan_plans a inner join sysmaintplan_subplans b on a.id=b.plan_id
    inner join sysmaintplan_log c on c.plan_id=b.plan_id and c.Subplan_id=b.subplan_id
    inner join sysmaintplan_logdetail d on d.task_detail_id=c.task_detail_id
    ORDER BY D.start_time DESC
    GO
    SELECT [ServerName],name,subplan_name,line2,
    Split.a.value('.', 'VARCHAR(100)') AS String
    FROM (SELECT [ServerName],name,subplan_name,line2,
    CAST ('<M>' + REPLACE([DBs], ',', '</M><M>') + '</M>' AS XML) AS Dbs
    FROM #test) AS A CROSS APPLY Dbs.nodes ('/M') AS Split(a);
    drop table #test
    anyways, on a side note, if you really have 5000 sql servers, you should looking at some tool or scripts to do this maintanence tasks than the builtin maintenance tasks as they provide better managebility. also, it is highly likely that you have multiple version,
    which makes it even harder to script out....
    Hope it Helps!!

Maybe you are looking for

  • Printing in iCal 1.5.5

    Is there a way in iCal for Panther to print the notes in the calendar event? Not the task list. Either just that event or all events in a month with the notes included.

  • Cannot edit/create new mailbox in ECP - Exchange 2013 CU6

    Hello, I am currently running Exchange 2013 CU6. I cannot perform tasks related to recipients such as edit/create new mailbox. Additionally I cannot view the properties of the virtual directories. I tried multiple browsers (Chrome, Firefox, IE) in di

  • In app purchase error in clash of clans.

    Hello, im making in app purchase in clash of clans. your purchase could not be completed" contact www.apple.com/support/itunes/ww/ of clans, and getting error conctact support. What should i do, credit card is good, there is money in it.

  • Can't merge both my Skype and Microsoft messenger ...

    Hello, I have 2 accounts (skype and Microsoft).  While following the "how to", I log into Skype using my Microsoft user ID, sign in without issues, it then prompts me if I have a skype account, which I type in, it recognizes it and accepts it, then a

  • How to make fields non editable in MM02

    My user wishes to have access to change only the Bin Location field in MM02. How can we achieve this? or in other words how can we deliver MM02 to user with only the Bin Location field editable. My basis guy sees a possibility if we can some how prov