Solved

query datediff btw different rows in the same table

Posted on 2003-10-21
3
1,611 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

837 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