Advertisement

06.24.2008 at 12:07AM PDT, ID: 23510066
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

Query Tuning

Asked by PHILIP233 in SQL Server 2005, Oracle 10.x, PL / SQL

Tags: , ,

SELECT DISTINCT BR.CUSTOMERCODE,
                DECODE(CUS.CUSTOMERTYPENUM,
                       1,
                       CUS.LASTNAME || ' ' || CUS.FIRSTNAME || ' ' ||
                       CUS.MIDDLENAME,
                       2,
                       CUS.COMPANYNAME,CUS.COMPANYNAME) CUSTOMERNAME,
                BR.BILLCURRENCYCODE CURRENCYCODE,
                BR.FRANCHISECODE FRANCHISE,
                DECODE(I.ITEMDESC, NULL, BR.VARIANTCODE, I.ITEMDESC) VARIANTDESCRIPTION,
                BR.VIN VIN,
                SN.MODELYEAR MY,
                SUM(BRD.BILLSAMOUNTTC) OVER(PARTITION BY BRD.BILLSREGISTERID) SETAMOUNT,
                SUM(BRD.INTERESTAMOUNTTC) OVER(PARTITION BY BRD.BILLSREGISTERID) INTAMT,
                (SUM(BRD.BILLSAMOUNTTC)
                 OVER(PARTITION BY BRD.BILLSREGISTERID) +
                 SUM(BRD.INTERESTAMOUNTTC)
                 OVER(PARTITION BY BRD.BILLSREGISTERID)) SETNET,
                BRD.BILLDUEDATE,
                BR.CURRENTSETNUMBER SETNUMBER,
                (SELECT SUM(BRD.BILLSAMOUNTTC)
                   FROM BILLSREGISTERDETAILS BRD1
                  WHERE BR.BILLSREGISTERID = BRD1.BILLSREGISTERID
                    AND (((BRD1.BILLDUEDATE <= '&PDATE') AND
                        (BRD1.SETTLEMENTDATE > '&PDATE' or
                        BRD1.SETTLEMENTDATE is null)))
                  GROUP BY BRD1.BILLSREGISTERID) OVERDUEAMOUNT,
                (SELECT SUM(BRD2.BILLSAMOUNTTC)
                   FROM BILLSREGISTERDETAILS BRD2
                  INNER JOIN BILLSREGISTER BR2 ON BR2.BILLSREGISTERID =
                                                  BRD2.BILLSREGISTERID
                                              AND ((BRD2.BILLDUEDATE >
                                                  '&PDATE' AND
                                                  (BRD2.SETTLEMENTDATE >
                                                  '&PDATE' OR
                                                  BRD2.SETTLEMENTDATE IS NULL)))
                                              AND BR2.CURRENTSETDATE <=
                                                  '&PDATE'
                  WHERE BR2.BILLSREGISTERID = BR.BILLSREGISTERID
                  GROUP BY BRD2.BILLSREGISTERID) UNDUEAMOUNT,
                TO_CHAR(BR.CURRENTSETDATE, 'DD-MON-YYYY') SETDATE,
                (BR.TOTALLOANAMOUNT / BR.EXCHANGERATE) LOANAMOUNT,
                TO_CHAR(MIN(BRD.BILLDUEDATE)
                        OVER(PARTITION BY BRD.BILLSREGISTERID),
                        'DD-MON-YYYY') FIRSTDUEDATE,
                TO_CHAR(MAX(BRD.BILLDUEDATE)
                        OVER(PARTITION BY BRD.BILLSREGISTERID),
                        'DD-MON-YYYY') LASTDUEDATE,
                BRD.BILLSAMOUNTTC,
                TO_CHAR(BRD.SETTLEMENTDATE, 'MON,YYYY') PAYMENTDATE,
                BRD.SETTLEMENTDATE BILLDUEDATE
  FROM BILLSREGISTER BR
  INNER JOIN BILLSREGISTERDETAILS BRD ON BR.BILLSREGISTERID = BRD.BILLSREGISTERID
  INNER JOIN CUSTOMER CUS ON CUS.CUSTOMERCODE = BR.CUSTOMERCODE
  LEFT OUTER JOIN ITEM I ON I.ITEMCODE = BR.VARIANTCODE
  LEFT OUTER JOIN SERIALNUMBER SN ON SN.VIN = BR.VIN
  WHERE BRD.BILLDUEDATE <= '&PDATE'
  ORDER BY BRD.BILLDUEDATE

Kindly verigy the above query.
Kindly suggest something to improve the performance.
Start Free Trial
[+][-]06.24.2008 at 12:16AM PDT, ID: 21853050

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 01:55AM PDT, ID: 21853564

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 03:21AM PDT, ID: 21853990

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 09:41AM PDT, ID: 21857643

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 03:25PM PDT, ID: 21861061

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.25.2008 at 02:24AM PDT, ID: 21863857

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, Oracle 10.x, PL / SQL
Tags: Oracle, Oracle 10g, 10g
Sign Up Now!
Solution Provided By: gajmp
Participating Experts: 4
Solution Grade: A
 
 
[+][-]06.28.2008 at 04:15AM PDT, ID: 21890226

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 02:59AM PDT, ID: 21914751

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628