Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Query tuning help needed
Ranga,
I think you probably want to change
,SUM(CASE WHEN t.TYPE IN ('OD','OT','TD','TT') THEN
NVL(TT_TIME_IN_MIN,0) seg_time
to
,SUM(CASE WHEN t.TYPE IN ('OD','OT','TD','TT') THEN
NVL(TT_TIME_IN_MIN,0)+(TD_TIME_IN_MIN,0)+(OT_TIME_IN_MIN,0)+(OD_TIME_IN_MIN,
0) seg_time
... this is not supposed to be an exact query, but just an idea to get rid of redundant SQL statement ...
Raj
-----Original Message-----
Sent: Tuesday, April 29, 2003 12:57 PM
To: Multiple recipients of list ORACLE-L
Brad, Ranga
I am sorry but I have to disagree, stored procedure is not an answer to this problem. I prefer to call this I-saw-a-new-feature-and-i-want-to-use-it syndrome.
How about following ...
SELECT ORIGIN
,DESTINATION ,SERVICE_CODE ,CASE WHEN SERVICE_CODE = 'X' THEN AVG(SEG_TIME) + 1 WHEN SERVICE_CODE = 'Y' THEN AVG(SEG_TIME) + 2 WHEN SERVICE_CODE = 'Z' THEN AVG(SEG_TIME) + 3 WHEN SERVICE_CODE = 'Q' THEN AVG(SEG_TIME) + 4 END AS ADD_ON_VALUE ,SYSDATE ,'SYSTEM' FROM (SELECT META_ROUTING_KEY AS ROUTE_KEY
,ST1.STATION_CODE AS ORIGIN
,ST2.STATION_CODE AS DESTINATION
,SERVICE_CODE
,SUM(CASE WHEN t.TYPE IN ('OD','OT','TD','TT') THEN
NVL(TT_TIME_IN_MIN,0) seg_time FROM SEG_MIN_TIMES M, STATION ST3, STATION ST4,PRY_TWO_MR_TRANSIT T, SERVICE WHERE M.ORIGIN = ST3.STATION_CODE AND M.DESTINATION = ST4.STATION_CODE AND ST3.STN_KEY = T.SEG_ORG_STN_KEY AND ST4.STN_KEY = T.SEG_DEST_STN_KEY AND M.SERVICE = SERVICE_CODE AND SERVICE_CODE IN ('X','Y','Z','Q') GROUP BY META_ROUTING_KEY, ST1.STATION_CODE, ST2.STATION_CODE,SERVICE_CODE )
Test and Test and Test ... this should give you an idea though ... Raj
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Jamadagni, Rajendra INET: Rajendra.Jamadagni_at_espn.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Tue Apr 29 2003 - 12:26:55 CDT
- text/plain attachment: ESPN_Disclaimer.txt
![]() |
![]() |