[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

07/02/2009 at 12:01PM PDT, ID: 24540590
[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!

8.4

Please explain code to display sales results into quarterly amout

Asked by nicolas-ca in PL / SQL

Tags: PL / SQL, Oracle, SQL

Dear, I have to maintain a script that displays a sales history data into quarterly buckets.  Data are summarized at quarter level; data are spread at daily level dividing by 7 the weekly quantity from the hist (sales history table).  A conversion factor is also applied.

I want to understand how the results is achieved using the:
SELECT 0 daily FROM DUAL UNION ALL
        SELECT 1 FROM DUAL UNION ALL
etc....
the above snippet gives:
Daily:
0
1
2
3
4
5
6

The results of the script for a particular article in in sheet Temp.xls attached.

Part of the the sales history data is found in Temp2.xls.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
SELECT  TO_CHAR(h.startdate+d.daily,'YYYY Q') yearq  , 
l.loc , 
d.articleCode    , 
ROUND(SUM((h.qty/7)/d.conversion)) qty  , 
'SALES' dem_source 
FROM hist h, article d, loc l , 
( SELECT 0 daily FROM DUAL UNION ALL
        SELECT 1 FROM DUAL UNION ALL 
        SELECT 2 FROM DUAL UNION ALL 
        SELECT 3 FROM DUAL UNION ALL 
        SELECT 4 FROM DUAL UNION ALL
        SELECT 5 FROM DUAL UNION ALL
        SELECT 6 FROM DUAL ) d
  WHERE l.loc = h.loc
    AND h.startdate >= (NEXT_DAY(TO_DATE('0101'||TO_CHAR(SYSDATE,'YYYY'),'DDMMYYYY'),'MONDAY')-7 )
    AND h.startdate <= NEXT_DAY(TRUNC(SYSDATE),'MONDAY')-14
    AND h.articleCode = d.articleCode
    and d.articleCode= '00300349'   
  GROUP BY  
      TO_CHAR(h.startdate+d.daily,'YYYY Q') 
    , l.loc, d.articleCode ;
Attachments:
 
Query results
 
 
Sales history data
 
[+][-]07/02/09 12:18 PM, ID: 24766772

View this solution now by starting your 30-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

Zone: PL / SQL
Tags: PL / SQL, Oracle, SQL
Sign Up Now!
Solution Provided By: awking00
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_EXPERT_20070906