Need help to re-format the query
Hi All,
Could any one please help me to rewrite this query or explain me how to do it as it is taking 20 mins to execute....
SELECT
AC.ACC_NO||DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.PAYMENT_SET
FROM
MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID= MI.MID AND RELATION='ROF')),MI.PAYMENT_SET)||
DECODE(MI.MSG_CLASS,'ROF', (SELECT LMI2.SERVICE FROM MIF LMI2 WHERE LMI2.MID = (SELECT CHILDMID FROM
MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),MI.SERVICE) HASH_KEY,
MI.MID ,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.PAYMENT_SET FROM MIF LMI2
WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.PAYMENT_SET) PAYMENT_SET,
MI.AMOUNT,
NVL(DECODE(MI.MSG_CLASS,'ROF',MI.CRAMOUNT, MI.DBAMOUNT) ,0) AMT,
AC.ACC_NO,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.BATCH_COMPANY_CD FROM MIF LMI2 WHERE
LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.BATCH_COMPANY_CD) BATCHCOMP,
AC.ACC_ALIAS, NVL(AC.IBAN,
NVL(AC.ACC_ALIAS,AC.ACC_NO)) IBAN_ACCNO,
AC.CURRENCY , AC.ACCOUNTNAME ,
CASE
WHEN (SIGN(MI.PROCESS_DT - TO_DATE(:B2 ,'YYYYMMDD'))) = '1'
THEN 'F'
ELSE 'C' END FUTURE_IND,
(CASE
WHEN (MI.MSG_STATUS = 'CANCELED' OR MI.STATBFHELD = 'CANCELED')
THEN 'C'
WHEN MI.BATCH_PAYMENT_TP = 'RMTRT'
THEN 'R'
WHEN (MI.REJECT_RETURN='REJT' OR MI.MSG_CLASS = 'ROF' OR MI.MSG_STATUS = 'REJECTED')
THEN 'A'
WHEN (MI.REJECT_RETURN='RETN' OR (MI.BATCH_PAYMENT_TP='RTACH' AND MSG_CLASS='ROF'))
THEN 'B'
WHEN MI.MSG_STATUS='FORWARD_PROCESSING'
THEN 'F'
WHEN (MI.MSG_STATUS NOT IN ('COMPLETE','CANCELED','REJECTED') OR (MI.MSG_STATUS='AGED' AND
MI.STATBFHELD NOT IN ('COMPLETE','CANCELED','REJECTED')) )
THEN 'U'
WHEN MI.PROCESS_DT = TO_DATE(:B2 ,'YYYYMMDD')
THEN 'P' END)
PAY_STATUS,
MT.DB_FEE_ACCOUNT_CCY,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM
MESSAGEFREETEXT
WHERE
FIELDNAME ='MANDATEREFERENCE'
AND MESSAGEFREETEXT.MID= MI.MID) MANDREF,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT
WHERE FIELDNAME ='DIRECT_DEBIT_REFERENCE' AND MESSAGEFREETEXT.MID=MI.MID) DDREF,
MT.CUSTOMER_BATCH_REFERENCE LOCINFO,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT WHERE FIELDNAME = 'SECOND_PARTY_ID' AND MESSAGEFREETEXT.MID=MI.MID) SECPRTYINF,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT WHERE FIELDNAME = 'HUB_PAY_PROD_TYP' AND MESSAGEFREETEXT.MID=MI.MID) PAYPRODTYP,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.CHANNEL_REFERENCE FROM MIF LMI2
WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.CHANNEL_REFERENCE) CHNREF,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT
WHERE FIELDNAME = 'CHN_BATCH_REF' AND MESSAGEFREETEXT.MID=MI.MID) CHNBATREF,
TO_CHAR(DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.VALUE_DATE FROM MIF LMI2
WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.VALUE_DATE),'DD/MM/YYYY') VALUEDT,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.ORIG_REFERENCE FROM MIF LMI2 WHERE LMI2.MID = (SELECT
CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),
MI.ORIG_REFERENCE) ORIGREF,
CASE
WHEN (MI.OFFICE <> MI.ORIG_OFFICE)
THEN MT.DR_SIDE_RATE_AM
ELSE
CASE
WHEN MI.DBCURRENCY = MI.CRCURRENCY
THEN
CASE
WHEN MI.CRCURRENCY = :B4
THEN MT.DR_RATE ELSE MT.CR_RATE
END
ELSE
CASE
WHEN MI.CRCURRENCY = :B4
THEN MT.DR_RATE ELSE MT.CR_RATE
END
END
END EXCHRT,
MT.BBK_ADDR1,
MT.BBK_ADDR2,
MT.BBK_ADDR3 ,
MT.BBK ,
MT.BNF_ADDR1,
MT.BNF_ADDR2,
MT.BNF_ADDR3,
MT.BNF_ADDR4 ,
MT.BNF ,
DECODE(MT.BNF_IDCODE,'AC',MT.BNF_ID,' ') ORGBNFID,
DECODE(NVL(MI.ORIG_INSTRUCT_AMOUNT,0),0, MI.ORIG_AMOUNT) ORGINSTAMT,
NVL(TRIM(MI.ORIG_INSTRUCT_CURRENCY), MI.ORIG_CURRENCY) ORGINSTCUR,
CASE
WHEN MOP LIKE 'DRFT%'
THEN 'DD'
WHEN MOP LIKE 'CHEQ%'
THEN 'CO'
WHEN MOP LIKE 'SWIFT'
THEN 'TT'
WHEN MOP LIKE 'DDP%'
THEN 'T'
WHEN MOP LIKE 'BOOK'
THEN 'T' ELSE 'LP'
END PYMTTP,
MT.OBI ,
TO_CHAR(MI.PROCESS_DT,'YYYYMMDD') PROCESSDT,
MI.REFERENCE,
MT.BBK_BIC,
MT.BBK_IDCODE,
DECODE(MT.BBK_IDCODE,'AC',' ',SUBSTR(MT.BBK_ID,1,12)) BBKID,
MI.LOCAL_REF,
MI.CURRENCY INDCURR,
MI.MSG_STATUS,
MI.PK_BATCH_SUBSET,
TO_CHAR(SBBATCH.PROCESS_DT,'YYYYMMDD') SBPROCESSDT,
DECODE(MI.MSG_CLASS,'ROF',MI.CRCURRENCY, MI.DBCURRENCY) DBCURR,
MI.ORIG_REFERENCE ORIGREFRET
FROM
MIF MI,
MTF1000 MT,
ACCOUNTS AC,
( SELECT
MF.PK_BATCH_SUBSET,
MF.PROCESS_DT,
MTF.ORG_ID,
MTF.MP_CR_ACC,
MTF.CR_ACC_NO
FROM
MIF MF,
MTF1000
MTF
WHERE
((MSG_STATUS IN ('COMPLETE','CANCELED','REJECTED')) OR
(MSG_STATUS = 'AGED' AND STATBFHELD IN ('COMPLETE','CANCELED','REJECTED')))
AND
BATCH_MSG_TP = 'S' AND MF.MID = MTF.MID )
SBBATCH
WHERE
MI.MSG_TYPE = :B3
AND MI.PROCESS_DT = TO_DATE(:B2 ,'YYYYMMDD')
AND MI.BATCH_MSG_TP = 'I'
AND DECODE(MI.MSG_CLASS,'ROF',
(SELECT LMI2.SERVICE FROM MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),MI.SERVICE)
IN ('NET','HCN','BIB','LST','MRI')
AND MI.PK_BATCH_EXCH IN (SELECT PK_BATCH_EXCH FROM BATCH_EXCH)
AND MI.MID = MT.MID
AND SBBATCH.PK_BATCH_SUBSET = MI.PK_BATCH_SUBSET
AND TRIM(DECODE(MI.MSG_CLASS,'ROF',MT.CR_ACC_NO, NVL(MT.ORG_ID,NVL(MT.MP_DB_ACC,MT.ACC_NO))) )=AC.ACC_NO
AND AC.OFFICE = :B1
ORDER BY HASH_KEY,PAY_STATUS
Hi,
please try this.
The first decode or at least part of it repeats at least 7 times.
DECODE(MI.MSG_CLASS,'ROF',
(SELECT LMI2.PAYMENT_SET
FROM MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')
),MI.PAYMENT_SET
||
DECODE(MI.MSG_CLASS,'ROF',
(SELECT LMI2.SERVICE
FROM MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')
),MI.SERVICE) HASH_KEY,
is similar to this
select mif.* from mif, mfamily where mif.mid=mfamily.childmid
and relation = 'ROF' and msg_class='ROF'
insert it as an inline view and add a conditition
from ...
(select mif.* from mif, mfamily where mif.mid=mfamily.childmid
and relation = 'ROF' and msg_class='ROF') rof
Where ...
and mi.mid=Rof.mid (+)...
and your code above would look like
nvl(rof.payment_set,mi.payment_set) || nvl(rof.service,mi.service) HASH_KEY,
nvl(rof.payment_set,mi.payment_set) PAYMENT_SET
replace all the same decode above with corresponding nvl(...)Hope this helps.
Similar Messages
-
Need Help in tuning of the query
Hi all,
Can any body help me how we can rewrite this query in
optimized way.
SELECT A.C1 AS COLUMN_1, B.C2 AS COLUMN_2
FROM A,B
WHERE A.C1 IN (
SELECT COLUMN_1 FROM(
(SELECT A.C1 AS COLUMN_1,
COUNT(C1) AS COUNT,
RANK() OVER (ORDER BY COUNT(C1) DESC) AS RANK
FROM A, B, C
WHERE A.C1 = B.C3
AND B.C2 = C.C1
AND <other conditions>
GROUP BY A.C1)
WHERE RANK <= 10)
AND A.C1 = B.C3
AND <other conditions>
ORDER BY A.C1
I am using <other conditions> are same in outer query and inner query also.
Thanks in Advance,Hi,
Yes exactly I am looking TOP-10 results the query is like this
SELECT A.C1 AS COLUMN_1, B.C2 AS COLUMN_2
FROM A,B
WHERE B.C2 IN (
SELECT COLUMN_1 FROM(
(SELECT B.C2 AS COLUMN_1,
COUNT(A.C1) AS COUNT,
RANK() OVER (ORDER BY COUNT(C1) DESC) AS RANK
FROM A, B, C
WHERE A.C1 = B.C3
AND B.C2 = C.C1
AND <other conditions>
GROUP BY B.C2)
WHERE RANK <= 10)
AND A.C1 = B.C3
AND <other conditions>
ORDER BY B.C2
Thanks -
Need help in rewriting a sql query
Can any one please tell me if there is any utility that can help me correcting the sql I have I need to tune the query as its taking lot of time. I want to use some tool that will help me re-formating the query.
Any help in this regard will be highly appreciated.If you think that Oracle SQL Tuning Tools like SQL Tuning Advisor and SQL Access Advisor are not helping.
You might look into thrid party tools like Quest- SQL Navigator and TOAD.
But I don't advise this based on the following:
Re: Oracle Third Party Tools and Oracle Database
Oracle have enough tools of its own to satisfy the various needs.
Adith -
Sql statement substituion - any special rules for formatting the query?
Hey,
I was wondering - are there any special rules for formatting the query that is to be substituted?
I am asking, as somehow I am unable to make the DSP substitute my query. I took the basesql from the server console (to make sure that I have the correct version), configured a query substitution, and well, nothing happens.
I've tried to substitute it with a modified version of the original query (where NVL(,0) is changed to NVL(,-9999)), then also with select * from dual (which I hope would generate some error), but DSP is ignoring everything...
The query is rather big (400 lines), so maybe I need to format it somehow? I've noticed that in the docs (http://edocs.bea.com/aldsp/docs25/admin/server.html#wp1049919) that the query used in the example has all leading spaces removed. I've tried that, but DSP is still not doing any substitution...
Any suggestions welcomed...
Thanks,
LeszekMichael,
I am doing everything as in edocs, retrieving from logs the basesql (so with place holders). I've removed all new lines (so the query is now in a single line) and all excessive blanks (so all double/more blanks replaced with a single blank). Still the DSP is like ignoring the substitution. I've tried to do it even with a simple query, like:
SELECT t4."PRODUCT_ID" AS c1, t4."PRODUCT_NAME" AS c2 FROM {DB}.{SELECTION} t1 JOIN {DB}.{CUSTOMER_FACT} t2 ON (t1."VAL" = t2."CUSTOMER_ID") JOIN {DB}.{CUSTOMER} t3 ON (t3."CUSTOMER_ID" = t2."CUSTOMER_ID") JOIN {DB}.{PRODUCT} t4 ON (t4."PRODUCT_ID" = t3."PRODUCT_ID") WHERE ((? = t1."SESSN_ID") AND (t1."NAME" = 'CUSTOMER_ID') AND (t3."DELET_DATE" IS NULL) AND (t3."PRODUCT_TYPE" = 11))
am I missing something here? do I need to remove/add something , to make it work?
I've tried removing blanks around = signs (which from the DSP pov results in a different query), sitll with no results.
Edited by xnts at 06/24/2008 7:37 AM -
I actually need help but cannot find the answer.
Please.......Lately when open a new tab it does not open with a blank page. I don't want to set my homepage as blank as when I first open Firefox, it automatically loads my hotmail page. But then if I open other pages I don't get a blank page. Help, please?
Thank you.
''[Personal information removed by moderator. Please read [[Forum and chat rules and guidelines]], thanks.]''hello, please refer to [[New Tab Page – show, hide and customize top sites]] in order to switch the feature off.
-
I buy for mac app but not for the iPad, so how do I reinstall a program that has already purchased? I need help because I bought the imovie'11 but when he opened it only brought 8 movie trailer templates instead of the 15 it says on the program. How do I solve this problem? Once paid for a program incomplete. I also liked that the AppStore itself had a button to reinstall programs already bought, because it is very hard to understand how to do this in the store, only option is to install and hide purchase, and how do I reinstall, attention'm talking about reinstalling a computer mac, not an ipad or iphone.
Thank you.Prodesigntools.com , go ahead and download the software from there and use your serial number to serialize it.
-
I get the following message when trying to open an .avi downloaded from my video cam, need help, can not find the codec, thank you. This is for Quicktime Player.
"The document “IMAG0026.AVI” could not be opened. A required codec isn't available."Try Perian.
http://perian.org/ -
Need help in PO Approval Group Query
Hi,
I need a Query which will list of users that has the Approval Group “BUYER” and “BUYER_DEMO” assigned to them.
It will be needful if anyone provides me the Query
Thanks and RegardsHi
Try this.
SELECT PAPF.employee_number
,PAPF.full_name
FROM po_control_groups_all PCGA
,po_position_controls_all PPCA
,per_all_assignments_f PAAF
,per_all_people_f PAPF
WHERE PCGA.control_group_name IN ('BUYER','BUYER_DEMO')
AND PCGA.control_group_id = PPCA.control_group_id
AND PPCA.position_id = PAAF.position_id
AND PAAF.person_id = PAPF.person_id
Thanks and Regards,
JD -
I need help in finding all the new fontsin iPad 2 using iOS 5
I need help in finding all the new fonts in ipad 2 using ios 5
You cannot change the email font. You can make it bold, italics and underline the type, but Helvetica is your only choice in the mail app.
In the notes app you have 3 choice Noteworthy, Helvetica and Marker Felt. The font can be changed in Settings>Notes>Font.
You can only use fonts that are built into the app that you are using at the time. You cannot pick and choose fonts from a list of all of the fonts that may be on the iPad but only from the list of fonts that the app allows. -
I forgot the code for my iPhone to access the Home screen I do , please help me
try formatting the iphone but when I put in nfc mode and connect it to the pc recognizes it and everything when you try to format the error 3004 appearsHello polo-angulo,
I apologize, I'm a bit unclear on the nature and scope of the issue you are describing. If you are saying that you are getting an error code (3004) when you try to restore your iPhone (because you could not remember your passcode), you may find the information and troubleshooting steps outlined in the following articles helpful:
Resolve iOS update and restore errors in iTunes - Apple Support
Get help with iOS update and restore errors - Apple Support
Sincerely,
- Brenden -
Yosemite made my MacBook Pro so slow !! Need help ? what is the solution?
Yosemite made my MacBook Pro so slow !! Need help ? what is the solution?
I've ran a benchmark on my Mac (iMac early 2009). Performance of Yosemite in general was about the same as Mavericks. But that can be different on other Mac's of course. Safari is mostly a bit slower. It's recommended you clean your old internet-caches and then restart Safari. (you can use a little app called CCleaner to do that). That might make a difference. Speed-issues are usually solved in the first and second update of OS X.
-
I need help! I updated the new 6.1.3 last night. Since that time my phone will not charge. The phone is plugged in and shows as charging but the battery still drains. What can I do? I need help!
Restore iPhone with iTunes on your computer.
-
I need help quick please sold the iPod and before handing it over wanted to clear out info so pushed erase now there is only a plug icon for iTunes but it won't now recognize my computer what can I do??
Try
iOS: Device not recognized in iTunes for Windows
or
iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X -
I had to put my computer by together without migration or time machine I NEED help with order of the files?
Hi, where are these other files exactly?
-
Need help with passcode using the "Remote" app
Hello and thanks in advance. I can't find a place on iTunes to enter the passcode from the Remote app.
PLEASE READ!!!
I have a HP Pavilion - Windows XP
I need help as well with the passcode. I went to Networking and Sharing center and clicked customize and changed the name to NetGear because that is what it says next to my WiFi on my iPhone but with my iPhone under Settings it says WiFi NETGEAR > but when I click on it, it says choose a Network. Is NETGEAR a network? How do I find or change to a Network? is this the problem?
Maybe you are looking for
-
How to I get play count on my iphone to show up in itunes on new mac?
I got a new macbook pro and downloaded the music from my other computer through homeshare. The play count on my phone would show up on the old computer but hasnt on the new mac even after syncing multiple times. I want the play count from the old com
-
How much does a sideloading key cost and do I need one for win 8.1 RT?
What is the cost for a sideloading key as of june 2014?
-
After activating "Click-to-play" plug-ins, I cannot open pdf files.
In the latest release of Firefox, information about how to prevent plug-ins from loading automatically was in the release notes. I activated this in about:config. (Click-to-play). After that, I cannot open pdf files! When I click on a link all I get
-
Send mail using cl_bcs. need text in mail body
Hi friends, please provide me some solution to send mail with out attachment and the message should only be in mail body. Code : TRY. * -------- create persistent send request ------------------------ send_request = cl_bcs=>create_persist
-
Fonts bolded on publish?
Hey Does anyone know why my iWeb pages have normal text when viewed in iWeb but most of the text suddenly appears to be bolded when I view the pages in any of the web browsers I have (Safari, Firefox, Omniweb...). I've tried trashing the preferences,