Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Please help with chart query

911160Jan 15 2012 — edited Jan 15 2012
Hello, i am trying to display a line chart, for some sales data.
I want a line (series) for each product, X axis should be the years in the data
(2007, 2008, 2009 there is no more data than these years)

The plan is to eventually use a "Function Returning SQL Query" to get dynamic series.
But i tried to hardcode 2 lines for 2 products first to try it out.

I used this query in SQL Workshop > SQL Commands
to view the data i want and it works correctly

Query1:
SELECT product.major_brand, timeperiod.year, SUM(sales_fact.euro_sales) AS sales
FROM sales_fact
INNER JOIN product ON sales_fact.product_id = product.product_id
INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
GROUP BY product.major_brand, timeperiod.year
ORDER BY product.major_brand, timeperiod.year ASC
I have tried the following query for the chart but it will show 2 flat lines
with the value 0 for each year.

Query2:
SELECT NULL
      ,timeperiod.year
      ,SUM(decode(product.major_brand, 'BELCINO', sales_fact.euro_sales, 0)) "BELCINO"
      ,SUM(decode(product.major_brand, 'BIORGANIC', sales_fact.euro_sales, 0)) "BIORGANIC"
FROM sales_fact
INNER JOIN product ON sales_fact.product_id = product.product_id
INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
GROUP BY product.major_brand, timeperiod.year
Thanks for reading,
Any help is appreciated!

Edited by: 908157 on 15-jan-2012 5:22

Edited by: 908157 on 15-jan-2012 5:22
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2012
Added on Jan 15 2012
3 comments
106 views