Solved

query datediff btw different rows in the same table

Posted on 2003-10-21
3
1,613 Views
Last Modified: 2013-12-11
Hello,

I have a table history like this

task    date                     id
start    Oct 1, 2003         abc
end     Oct 3, 2003         abc

I would like find out any id which datediff(day, end, start) >=2,

how can I do this?

Thanks in advance,

Aventis

0
Comment
Question by:aventis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
Pontis earned 50 total points
ID: 9595930


 select distinct id from (select id, date - lag(date)   over (partition by id order by task desc)  diff from table) where diff>=2
/

Analytical functions rule! :)
 
0
 
LVL 22

Expert Comment

by:Helena Marková
ID: 10279136
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Pontis's comment as answer.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Henka
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle DR - data guard failover. 18 74
Read XML values 8 70
update using pipeline function 3 47
construct a query sql 11 43
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question