Operational Data Store Schema Reference

Operational Data Store Schema Reference

SQL Query Examples

SQL Query Examples

You access and retrieve information from the operational data store with SQL queries according to the type of report or analysis that you want to perform. The following examples show SQL queries that run on the operational data store to retrieve information for different reports.
Number of Events by Partner
Gets the total number of events that
B2B Data Exchange
processed during a time frame and displays the results sorted by the related partner for the event.
select topData.PARTNER_ID, dp.PARTNER_NAME, topData.SUM_COUNT from (select facts.PARTNER_ID, sum(EVENT_COUNT) as SUM_COUNT from DX_ODS_EVENT_FACTS facts where to_timestamp('2012-01-01' || '00:00:00','YYYY-MM-DD HH24:MI:SS') <= facts.TIMESLICE and facts.TIMESLICE <= to_timestamp('2012-06-01' || '00:00:00','YYYY-MM-DD HH24:MI:SS') ) group by facts.PARTNER_ID order by SUM_COUNT desc ) topData join DX_ODS_PARTNER dp on topData.PARTNER_ID = dp.PARTNER_ID order by topData.SUM_COUNT desc, dp.PARTNER_NAME asc
The query uses the to_timestamp parameter that defines the event processing start and end date and time.
The following table shows an example of the query results:
PARTNER_ID
PARTNER_NAME
SUM_COUNT
1000
My partner A
14781
1002
My partner C
12920
1001
My partner B
65044
Number of Events by Partner with Access Restrictions
Gets the total number of events that
B2B Data Exchange
processed during a time frame and displays the results sorted by the related partner for the event. This query also applies access restrictions by indicating which
B2B Data Exchange
users can view the results.
select topData.PARTNER_ID, dp.PARTNER_NAME, topData.SUM_COUNT from (select facts.PARTNER_ID, sum(EVENT_COUNT) as SUM_COUNT from DX_ODS_EVENT_FACTS facts where to_timestamp('2012-01-01' || '00:00:00','YYYY-MM-DD HH24:MI:SS') <= facts.TIMESLICE and facts.TIMESLICE <= to_timestamp('2012-06-01' || '00:00:00','YYYY-MM-DD HH24:MI:SS') and (exists (select ua.ACCESS_ID from DX_ODS_USER_ACCESS ua where ua.ACCESS_ID = facts.ACCESS_ID and ua.USER_ID = 999) or exists (select * from DX_ODS_USER_SUPER ua where ua.USER_ID = 999) ) group by facts.PARTNER_ID order by SUM_COUNT desc ) topData join DX_ODS_PARTNER dp on topData.PARTNER_ID = dp.PARTNER_ID order by topData.SUM_COUNT desc, dp.PARTNER_NAME asc
The query uses the following parameters:
  • to_timestamp. Defines the event processing start and end date and time.
  • USER_ID. Numeric identifier for the
    B2B Data Exchange
    user that can view the events. In this example, you define a single user that can view the events.
The following table shows an example of the query results:
PARTNER_ID
PARTNER_NAME
SUM_COUNT
1000
My partner A
14781
1002
My partner C
12920
1001
My partner B
65044
Custom KPI Query with Event Attribute Value
Gets the value of the ClaimValue event attribute and displays total claim value amount for the time frame grouped by the related partner for the event.
DEFINE fromDate = to_timestamp('01-03-2012 00.00.00.00', 'DD-MM-YYYY HH24.MI.SS.FF'); DEFINE toDate = to_timestamp('05-03-2012 23.59.59.00', 'DD-MM-YYYY HH24.MI.SS.FF'); DEFINE eventAtt = "'ClaimValue'"; SELECT p.PARTNER_ID, NVL(VALUE_SUM, 0) AS VALUE_SUM FROM (SELECT p.PARTNER_ID, SUM(VALUE_SUM) AS VALUE_SUM FROM DX_ODS_CUSTOM_FACTS cf JOIN DX_ODS_EVENT_FACTS ef ON ef.ROW_ID = cf.FACT_ROW_ID JOIN DX_ODS_PARTNER p ON ef.PARTNER_ID = p.PARTNER_ID JOIN DX_ODS_CUSTOM_FACTS_EAV cfe ON cf.EVENT_ATTRIBUTE_ID = cfe.ID WHERE cf.TIMESLICE >= &fromDate AND cf.TIMESLICE < &toDate GROUP BY p.PARTNER_ID ) SUM_ATT RIGHT JOIN DX_ODS_PARTNER p ON SUM_ATT.PARTNER_ID = p.PARTNER_ID
The query uses the following parameters:
  • fromDate. Defines the claim value processing start date and time.
  • toDate. Defines the claim value processing end date and time.
  • eventAtt. Name of the event attribute from which to get the value.
The following table shows an example of the query results:
PARTNER_ID
VALUE_SUM
1000
544
1002
1060
1001
865

0 COMMENTS

We’d like to hear from you!