SQL query - help needed [message #309024] |
Wed, 26 March 2008 04:36  |
shahnazurs
Messages: 240 Registered: June 2005 Location: India
|
Senior Member |
|
|
Hi,
I need to select the max time for the transaction using the below query. I’m able to get the o/p. Here the problem is I need to fetch the corrletorid (primary key) as well. if try to get that I’m getting the o/p like case2.
I want the o/p to be like case 1 with the corrleator id . please help me to get the o/p.
Case 1: select b.TransactionName, max(to_char(b.duration, 'mm/dd/yyyy hh24:mi:ss.ff')) as average from trandetails a,subtrandetails b where a.CORRELATORID=b.PCORRELATORID and b.PCORRELATORID='11' group by b.transactionname
TRANSACTIONNAME MAXTIME
------------------------- -----------------------------
FINT3 12/10/2007 19:53:09.042000
FINT 12/10/2007 19:31:07.042000
FINT2 12/10/2007 19:31:07.042000
SQL> /
Case 2: select b.TransactionName,b.correlatorid, max(to_char(b.duration, 'mm/dd/yyyy hh24:mi:ss.ff')) as average from trandetails a,subtrandetails b where a.CORRELATORID=b.PCORRELATORID and b.PCORRELATORID='11' group by b.transactionname,b.correlatorid
/
SQL> /
TRANSACTIONNAME CORRELATORID AVERAGE
------------------------- -------------------- -----------------------------
FINT2 102 12/10/2007 19:31:07.042000
FINT3 108 12/10/2007 19:53:09.042000
FINT3 103 12/10/2007 19:31:07.042000
FINT 101 12/10/2007 19:31:07.042000
in the above output i should have only record(max time) for FINT3.
Thanks
|
|
|
|
|