Home » SQL & PL/SQL » SQL & PL/SQL » sql query beteem two times (merged)
sql query beteem two times (merged) [message #301153] Tue, 19 February 2008 06:06 Go to next message
tannad
Messages: 43
Registered: January 2008
Location: mumbai
Member
Hi all Suppose my table is as follows.

Activitytime Person Flag
9:00 AM RaJ 0
9:10 AM RAj 1
9:45 Am RAj 1
9:50AM '' 0
9:55Am ,, 1

How I get the total duration between two time or two flag?
As
start_time stop_time Duration
9:00AM 9:45Am 45 min
Re: sql query beteem two times [message #301156 is a reply to message #301153] Tue, 19 February 2008 06:14 Go to previous messageGo to next message
nagaa
Messages: 33
Registered: August 2007
Location: chennai
Member
call the time function before start and end of the function..
Ex:
call_time("print current time")
insert()
{
------------insert statement here-------
}
call_time("print current Time")

Regards,
Nagaa


Re: sql query beteem two times [message #301158 is a reply to message #301156] Tue, 19 February 2008 06:21 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
huh?
Could you please elaborate that with a working sqlplus example?
Re: sql query beteem two times [message #301174 is a reply to message #301153] Tue, 19 February 2008 07:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
LAG

Regards
Michel
Re: sql query beteem two times [message #301289 is a reply to message #301153] Tue, 19 February 2008 23:59 Go to previous messageGo to next message
tannad
Messages: 43
Registered: January 2008
Location: mumbai
Member
my table is TEST
as follows

Activity_ time user flag
9:00 harshal 1
9:10 harshal 1
9:15 harshal 1
9:45 harshal 0
10:00 patil 1
10:10 patil 1
10:15 patil 0

when the flag 1 activity start and when the flag 0 activity stop

output will be in this manner
Starttime stoptime user Duration
9:00 9:45 harshal 45 min
10:00 10:15 patil 15min

please can you explain mi what will be the sql query for this
Re: sql for time duration [message #301298 is a reply to message #301153] Wed, 20 February 2008 00:22 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Same answer as your previous topic, have a look at LAG function.
I merge the 2.

"when the flag 1 activity start" but when there are several flag=1 then activity starts several times?

You have to post a test case: create table and insert statements.
Also post the result you want with these data.
You also have to read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel

[Updated on: Wed, 20 February 2008 00:26]

Report message to a moderator

Re: sql query beteem two times [message #301353 is a reply to message #301156] Wed, 20 February 2008 03:26 Go to previous messageGo to next message
tannad
Messages: 43
Registered: January 2008
Location: mumbai
Member
can you give the brif for your answer?
Re: sql query beteem two times [message #301358 is a reply to message #301353] Wed, 20 February 2008 03:36 Go to previous message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Can you give me a test case?

Regards
Michel
Previous Topic: ORA-01810: format code appears twice
Next Topic: Order By
Goto Forum:
  


Current Time: Thu Feb 13 10:10:36 CST 2025