Home » SQL & PL/SQL » SQL & PL/SQL » Dimension Mapping For Data Continuity - using Oracle SQL/PL/SQL (Oracle 11gR2, RHL 5 EE)
Dimension Mapping For Data Continuity - using Oracle SQL/PL/SQL [message #613212] Wed, 30 April 2014 23:54 Go to next message
suresh1985xp
Messages: 1
Registered: April 2014
Junior Member
We need to display counts (as zeroes) for dimensions whose actual data is missing.

We have the following original selection query:

SELECT a.dim1, a.dim2, a.dim3, COUNT(*) DATA_COUNT, SUM(dim10) DATA_SUM 
FROM  tabX a, ref_tabY b, ref_tabZ c
WHERE a.date_field BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE)-30
AND a.dim11 = b.d16(+)
AND a.dim12 = c.d15(+) 
AND a.dim9 IN (1,2,4);

We have created a trend report based on the above query. At present, if we do not have data in tabX for any particular day, say day3, day4, day5 of the last week, the trend graph still shows a continuos line. As per recent requirement, the plot should show BREAKS in those places displaying No data available during these days.

Another requirement is to be able to drill down on each dimensions. For example, if the user selects dim1 in first level drill the corresponding data needed to be displayed. In case, there's no available records, we need to display zero (0).

As a solution, we were thinking of creating a time dimension table and CROSS (cartesian) join the same with the available combinations of all these drillable dimensions. Next, LEFT OUTER JOIN the above set with the original query with Joining Keys on each of the drillable dimensions.

Can anyone suggest or guide us in any other possible solutions. Our approach does not have configurable options so would be unmanageable later if new dim came up. Plus, it will take huge time.

We are using Oracle 11g R2 on Linux RHL5.
The tabX have 5 GB data / day, range partitioned on date_field. The ref tables are reference tables for lookups (indexed).
Re: Dimension Mapping For Data Continuity - using Oracle SQL/PL/SQL [message #613221 is a reply to message #613212] Thu, 01 May 2014 04:21 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
suresh1985xp wrote on Thu, 01 May 2014 10:24
We need to display counts (as zeroes) for dimensions whose actual data is missing.


Use NVL


EDIT : If I understand correctly, you should get the COUNT as ZERO for cases where data is missing, however, the SUM should be NULL. Could you please post a working test case and explain in details about your requirement.

[Updated on: Thu, 01 May 2014 04:27]

Report message to a moderator

Previous Topic: Instead of trigger not supporting blob
Next Topic: need function convert time digit to analog
Goto Forum:
  


Current Time: Thu Apr 25 05:12:14 CDT 2024