sql - subquery in oracle 10g -
I have a table in the Oracle 10G database with the following columns
sdate sid Event 31 / 10/2013 20:20:20 1a 31/10/2013 20:20:21 1b 31/10/2013 20:20:22 1C 31/10/2013 20:41:04 2A31 / 10/2013 20:41:10 2b 31/10/2013 20:42:20 2C 31/10/2013 20:42:49 2C 31/10/2013 21:20:50 3A 31/10 / 2013 21: 21: 33 3b 31/10/2013 21:23:00 3C 31/10/2013 21:08:20 4b 31/10/2013 21:11:20 4c 31/10/2013 21:17: 20 4C 31/10/2013 22:20:20 5C 31/10/2013 22:22:22 5D
sdate < / Em> is the date of this record, sid is like a session ID, a unique occurrence within the event session Is A, B, C etc. A session should always start with an event of event 'A'. Other events like B, C can repeat.
Can someone help me in writing a question which will give me a list of all the SIDs, which begins with any other incident other than 'A', for example sid 4 and 5 The tese sessions begin with B and C.
Update: The actual events in my table are brief events in A, B, C, a long string
You can use analytical function for this purpose:
* From (select T. *, Row_number ()) (as part of sdate by sid command) from table to seqnum) where seqnum = 1 and event
based onsid date
row_number ()
. The where
section first selects all such rows where the event is not 'A'
.
Comments
Post a Comment