Hi,
I was hoping someone here is able to help me out, more of a general SQL query maybe but it is on a 10g database!
Some what simplified I have two tables:
PACKAGES
id name desc
----------------------
1 namea aaaaaa
2 nameb bbbbbb
3 namec cccccc
4 named dddddd
EVENTS
id code date
----------------------
1 A 20070103
1 B 20070104
1 X 20070106
2 B 20070107
2 C 20070106
3 A 20070108
3 B 20070108
3 C 20070109
3 D 20070109
3 X 20070110
4 X 20070112
For each package I want to retrieve the earliest event date from that packages events. But only for event of code A,B or C.
So the result should come out something like:
RESULTSET
id date
----------------
1 20070103 (code A)
2 20070106 (code C)
3 20070108 (code A and B)
4 (no code of type A,B or C)
I was hoping this would be possible using one query as opposed to doing an extra query (in the java code)
for each PACKAGE to get the EVENT time...
Stored procs are not an option
Any help appreciated.
Cheers!
Jan
I was hoping someone here is able to help me out, more of a general SQL query maybe but it is on a 10g database!
Some what simplified I have two tables:
PACKAGES
id name desc
----------------------
1 namea aaaaaa
2 nameb bbbbbb
3 namec cccccc
4 named dddddd
EVENTS
id code date
----------------------
1 A 20070103
1 B 20070104
1 X 20070106
2 B 20070107
2 C 20070106
3 A 20070108
3 B 20070108
3 C 20070109
3 D 20070109
3 X 20070110
4 X 20070112
For each package I want to retrieve the earliest event date from that packages events. But only for event of code A,B or C.
So the result should come out something like:
RESULTSET
id date
----------------
1 20070103 (code A)
2 20070106 (code C)
3 20070108 (code A and B)
4 (no code of type A,B or C)
I was hoping this would be possible using one query as opposed to doing an extra query (in the java code)
for each PACKAGE to get the EVENT time...
Stored procs are not an option
Any help appreciated.
Cheers!
Jan