How to query a cube using SQL ?

Hi I have a MOLAP cube say CubeA with dimensionA having Attribute A1 and dimensionB having attribute B1
the measure of cube is M1.
Any idea how i can query the cube using SQL dislaying both the dimensions with the measure interlinking them.
I just need a general overview of how to sql query a cube .. I have the dimensions and sttributes and name of the cube but i ineed to know how to query it... I was given an example
SELECT
t.time_long_description,
p.product_long_description,
c.customer_long_description,
f.sales,
f.sales_ytd
FROM
time_calendar_view t,
product_std_view p,
customer_std_view c,
sales_cube c
WHERE
t.dim_key = f.time
AND p.dim_key = f.product
AND c.dim_key = f.customer
AND t.level_name = 'CALENDAR QUARTER'
AND p.level_name = 'BRAND'
AND c.level_name = 'STATE';
but i cant understand it.. i cant figure out what are the dimensions and where are the attributes...
Any idea would great...

There's a nice tutorial here: http://st-curriculum.oracle.com/obe/db/11g/r1/olap/cube/querycubes.htm
Here are a few basics. Note that the link between the dimensions is the join between the dimension or hierarchy views and the cube.
* The primary key to every dimension and hierarchy view is DIM_KEY.
* The primary key to the fact table is dim1, dim2, dim3, so all joins are between dim_keys and dim1, dim2, etc.
* Dimension, hierarchy and cube views contain rows for both leaf (detail) and summary rows (that means cubes can return very, very large numbers of rows is you aren't careful)
* You typically want to query for the aggregate level data rather than use SUM ... GROUP BY. Let the cube do the work and let it manage calculations.
* Dimension views contain rows for all dimension member. hierarchy views contain rows for only members of the hierarchy.
* You typically select one of the long or short description columns to display data within an application.
Here's a commented version of your query:
SELECT
t.time_long_description, -- long descriptions
p.product_long_description,
c.customer_long_description,
f.sales, --measures
f.sales_ytd
FROM
time_calendar_view t, --hierarchy views
product_std_view p,
customer_std_view c,
sales_cube c --cube view
WHERE
t.dim_key = f.time ; -- joins between hierarchy and cube views
AND p.dim_key = f.product
AND c.dim_key = f.customer
AND t.level_name = 'CALENDAR QUARTER' -- Filters to ask for data at the quarter
AND p.level_name = 'BRAND' -- brand
AND c.level_name = 'STATE'; -- and state levels.
You want to have a filter on every dimension to avoid return all rows in the fact table for that dimension (remember, the cube contains summary rows). If you want to drop a dimension from a query (e.g., you don't want product in the query, intending for the query to be the aggregate of all products), filter to an all/total level.
e.g.,
and p.level_name = 'ALL PRODUCTS'
or
and p.long_description = 'All Products'
There are many variation of this query, but if you understand the basics you'll work your way there.
And, never do a select count(*) from a cube. Doing so will select the entire cube, detail and summary data.

Similar Messages

  • How to get this output using sql query?

    Hi,
      How to get this output using sql query?
    Sno Name Age ADD Result
    1 Anil 23 delhi Pass
    2 Shruti 25 bangalor Pass
    3 Arun 21 delhi fail
    4 Sonu 23 pune Pass
    5 Roji 26 hydrabad fail
    6 Anil 28 delhi pass
    Output
    Sno Name Age ADD Result
    1 Anil 23 delhi pass
    28 delhi pass

    Hi Vamshi,
    Your query is not pretty clear.
    write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
    Regards,
    Kannan

  • How to hide repeated details using SQL Query?

    How to hide repeated details using SQL Query?
    For Ex:
    ------------------------+
    DEPTNO| ENAME | JOB |
    ------|-------| --------|
    10 | JAMES | MANAGER |
    10 | BLAKE | CLERK |
    10 | FORD | SALESMAN|
    20 | SCOTT | MANAGER |
    20 | ADAMS | CLERK |
    20 | KING | SALESMAN|
    ------------------------+
    How we can display the above details in the following way?
    ------------------------+
    DEPTNO| ENAME | JOB |
    ------|-------| --------|
    10 | JAMES | MANAGER |
    | BLAKE | CLERK |
    | FORD | SALESMAN|
    20 | SCOTT | MANAGER |
    | ADAMS | CLERK |
    | KING | SALESMAN|
    ------------------------+
    Thanks Advance

    Hi,
    you can use BREAK ON DEPTNO in SQL*Plus or use LAG.
    SQL> ed
    Wrote file afiedt.buf
      1  select nullif(department_id
      2                , lag(department_id) over (partition by department_id order by last_name)
      3         ) dept_id
      4  , last_name, job_id
      5*  from employees where department_id in (30,50) and rownum <=10
    SQL> /
       DEPT_ID LAST_NAME                 JOB_ID
            30 Baida                     PU_CLERK
               Colmenares                PU_CLERK
               Himuro                    PU_CLERK
               Khoo                      PU_CLERK
               Raphaely                  PU_MAN
               Tobias                    PU_CLERK
            50 Fripp                     ST_MAN
               Kaufling                  ST_MAN
               Vollman                   ST_MAN
               Weiss                     ST_MAN
    10 rows selected.

  • Build essbase cube using Sql query.....

    Hi Team, Can we build dimensions as well as load data into essbase cubes using sql query generated from cognos cube. If so , please guide me the procedure

    I'm not sure about cognos, if you can create an ODBC connection you can try using that in SQL load rules and see if that works.
    Opening an SQL Database
    Regards
    Celvin
    http://www.orahyplabs.com

  • How to view alerlog contents using SQL?

    How to view alertlog contents using SQL?

    Hi,
    Why don't you use the OEM Database Console ?? Now, in order to view the contents of the alert log file using a SELECT statement, you need to create a external table:
    create or replace
    directory background_dump_dest_dir
    as '<your_oracle_home>/bdump';
    CREATE table alert_log_external
    (line varchar2(4000) )
    ORGANIZATION EXTERNAL
    (TYPE oracle_loader
    DEFAULT DIRECTORY background_dump_dest_dir
    ACCESS PARAMETERS (
    RECORDS DELIMITED BY newline
    nobadfile
    nologfile
    nodiscardfile
    FIELDS TERMINATED BY '#$~=ui$X'
    MISSING FIELD VALUES ARE NULL
    (line)
    LOCATION ('alert_<sid_of your_database>.log') )
    REJECT LIMIT UNLIMITED;Cheers

  • How to create olap cube using Named Query Table in Data source View

     I Create on OLAP Cube using Existing Tables Its Working Fine But When i Use Named Query Table with RelationShip To other Named query Table  It Not Working .So give me some deep Clarification On Olap Cube for Better Understanding
    Thanks

    Hi Pawan,
    What do you mean "It Not Working"? As Kamath said, please post the detail error message, so that we can make further analysis.
    In the Data Source View of a CUBE, we can define a named query. In a named query, you can specify an SQL expression to select rows and columns returned from one or more tables in one or more data sources. A named query is like any other table in a data source
    view (DSV) with rows and relationships, except that the named query is based on an expression.
    Reference:Define Named Queries in a Data Source View (Analysis Services)
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to view clob data using sql

    Hi,
    In our database, we have one table that is having one column of CLOB datatype but now i want to view the data using sql select query but it throws error: "Datatype not supported".
    Could any one please let me know how to view the clob data using select query.
    Oracle DB version : 10.2.0.3
    Thanks

    h5.
    use read procedure
    PROCEDURE READ (
    lobsrc IN BFILE|BLOB|CLOB ,
    amount IN OUT BINARY_INTEGER,
    offset IN INTEGER,
    buffer OUT RAW|VARCHAR2 );
    example  Updating LOB by Using DBMS_LOB in PL/SQL
    DECLARE
    lobloc CLOB; -- serves as the LOB locator
    text VARCHAR2(32767):='Resigned: 5 August 2000';
    amount NUMBER ; -- amount to be written
    offset INTEGER; -- where to start writing
    BEGIN
    SELECT resume INTO lobloc
    FROM employees
    WHERE employee_id = 405 FOR UPDATE;
    offset := DBMS_LOB.GETLENGTH(lobloc) + 2;
    amount := length(text);
    DBMS_LOB.WRITE (lobloc, amount, offset, text );
    text := ' Resigned: 30 September 2000';
    SELECT resume INTO lobloc
    FROM employees
    WHERE employee_id = 170 FOR UPDATE;
    amount := length(text);
    DBMS_LOB.WRITEAPPEND(lobloc, amount, text);
    COMMIT;
    END;

  • Query to cube using rscrm_bapi

    can we load data from a query with newselection to cube using rscrm_bapi.
    During  check these warings occurs
    Key figure  (F) is not a basic key figure
    Key figure  has no fixed currency; requires currency conversion
    please suggest
    Regards,
    Raj

    Hi All,
    I have already tried with APD, but no luck.....
    following error occurs
    while executing APD, following error occurs
    The technical field name KYF_0001 for field D56LC57R0X09TDN1TCY56IDF4 may only appear once per input or output structure....
    and then no execution is possible and that particular field has been mapped between source and target.
    also have query with char structure
    so then started with RSCRM_BAPI........in here i have structure in cloumns with new selection and new formula..........and now i get this messg
    Key figure  (F) is not a basic key figure
    Key figure  has no fixed currency; requires currency conversion.........(how do i check this......at cube level one one currency........)
    help needed
    Regards,
    Raj.

  • How to change field size using SQL against an oracle Database

    I am an admitted novice user, looking to become more proficient.
    I have a field in a table that I need to expand the field size. The table is called Inquiries. The data type is text. The current Field Size is 10. I want to increase it, to either the max, or somethign long enough to fit TECHNOLOGY LEADERSHIP PROGRAM.
    What is the SQL command to change the field size, and what is the max for a Text Field Size

    And/Or, an even better question might be,
    Do I need to use SQL*PLUS to do this, or are there better tools. I.e, I like how in Access, you can open up a database in Design view and just change the amount for the field size. Is there a similar "easy" method to do something like that with an Oracle database.
    My current version of the server/database is:
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning option
    JServer Release 9.2.0.6.0 - Production
    I was thinking I had to do SQL commands to perform the action, but there may be another way that I am not thinking about with all of the tools at my disposal. When I installed Oracle on my desktop, I installed most of the management tools and networking services, if that helps

  • How to export&import data using sql *loader

    Hi all,
    How to export&import data from sql*loader. Give me the clear steps..
    Thanks in Advance

    Hi did you already exported data from SQL SERVER? if not using SQL*LOADER you cannot export data. SQL*LOADER is only mean for importing data from flat files(usually text files) into ORACLE tables.
    for importing data into oracle tables using sql*loader use below steps
    1) create a sql*loader control file.
    it looks like as follows
    LOAD DATA
    INFILE 'sample.dat'
    BADFILE 'sample.bad'
    DISCARDFILE 'sample.dsc'
    APPEND
    INTO TABLE emp
    TRAILING NULLCOLS
    or for sample script of control file search google.
    2) at command prompt issue following
    $ sqlldr test/test
    enter control file=<give control file name which you create earlier>
    debug any errors (if occured)

  • How to load jar file using SQL Developer

    Dear All,
    I need urgent help to load mytest.jar to the database using SQL Developer. I am able to load individual java classes to the database using SQL developers, but i could not load JAR files. Please help me any one know how to do this using SQL Developer.
    Thanks and Regards
    John p

    I don't think that's possible, so load it through the OS with the loadjava utility.
    Have fun,
    K.

  • How we can update cube using Change Tables as Source

    I have created a cube using source tables. I have also created change table (feature of 9i) based on source table. which store new changes to souce table. I want to load cube using one mapping from source table or change table based on the validity of the change table.
    Is that possible to do this? have anybody implemented change table to incremental load of cube?
    Sanjiv Tyagi

    Hi Sanjiv,
    I can think of 2 ways of doing this:
    one is using a single mapping with a pre mapping process to determine whether the change table is valid. If yes the pre mapping process creates a view (that is also referenced in the mapping itself) on top of the change table (select * from change_table), if this is not valid then the view will be on the source table (select * from source). After this pre map process the mapping runs on which ever view exists and loads the data.
    the second way is using process flow and 2 mappings. In PF you have a PL/SQL call that verifies which data to use. If the change table is correct, that will give success and uses the mapping on the change table. If the return is Error then you use the mapping on the source table.
    I have not implemented these solutions, however I think these are 2 ways of getting it to behave like you would want to...
    Hope this gives you some ideas,
    Jean-Pierre

  • How to connect java database using sql....????

    Hey guys,
    I am a novice in Java Programming.Could someone help me out in connecting to sql.Im using Sql 2000 edition.
    Thanks.

    Google for "Sun JDBC tutorial" and go through it.
    %

  • How to view /SAPAPO/ tables using SQL Studio question

    Hi,
    This is for Livecache 7.4 on AIX.
    I have installed a SQL Studio 7.6. When I logged using SUPERDBA/admin, I can only see tables owned by SUPERDBA, SYS, and DOMAIN.
    I cannot see any tables owned by SAP<LC Name>. I want to see details about table e.g. /SAPAPO/ORDKEY, which is owed by SAP<LC Name>.
    Is it possible to see it using SQL Studio?
    Please let me know if anybody has any idea about it.
    Regards.
    Sume.

    Hello Sume,
    If you would like to see details about table e.g. /SAPAPO/ORDKEY.
    =>
      Did you check the owner of this table?
    => You could check, for example, in LC10 -> liveCache:Monitoring
    -> Problem Analysis -> Tables/Views/Synonyms ->
       Database Object Schema           SAPLCT
       Name of Database Object          *
       < execute >
       & review if the table /SAPAPO/ORDKEY is listed.
    => If the table is listed, you should be able to run the select statement as SAPLCT user on this table.
    If you are sure that you was using the SAPLCT user, please
    Check if this user has application tables:
    < May be the password was changed from the default sap for the
    Standard liveCache user, you should know it. >
    dbmcli -d LCT -u control,control
    dbmcli on LCT>sql_connect SAPLCT,sap
    dbmcli on LCT> sql_execute select * from users
    dbmcli on LCT> sql_execute select * from users
    < I would like to see what DBA users you have in liveCche &
      when the SAPLCT user was created. >
    dbmcli on LCT>sql_execute select tablename from tables where owner='SAPLCT'
    < If the SAPLCT is the owner of the liveCche application tables,
      and the table /SAPAPO/ORDKEY will be listed. >
    dbmcli on LCT> sql_execute select * from tables where owner='SAPLCT'
    dbmcli on LCT> sql_execute select count(*) from "SAPLCT"."/SAPAPO/ORDKEY"
    < to get number of the entries in the table with owner - SAPLCT >
    dbmcli on LCT>exit
    You could also to check what user did you set for the LCA connection.
    And run //om16 transaction in the liveCache relevant client on the system
    to see the entries in the /sapapo/ordkey & /sapapo/ordmap in liveCache in this client.
    Question: What details you need about table /SAPAPO/ORDKEY?
              Do you have problems on your system?
    Thank you and best regards, Natlia Khlopina

  • How to load date column using sql loader

    Hi,
    I am trying to load a file using sql loader. my date value in the file is '2/24/2009 8:23:05 pm',
    In control file for this column i specified like this
    rec_date date ''mm/dd/yyyy hh:mi:ss pm"
    But i am getting following error
    not avalid month.
    Thanks
    sudheer

    Hi,
    Use this example as reference:
    CTL file:
    LOAD DATA
    INFILE 'test.txt'
    BADFILE 'test.bad'
    truncate INTO TABLE T3
    FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '|' TRAILING NULLCOLS
    dt_date DATE "mm/dd/yyyy hh:mi:ss pm")DAT file:
    2/24/2009 8:23:05 pm
    C:\ext_files>sqlldr hr/hr control=test.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Wed Jul 1 20:35:35 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 1
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> desc t3;
    Name    Type Nullable Default Comments
    DT_DATE DATE Y                        
    SQL> select to_char(dt_date, 'mm/dd/yyyy hh24:mi:ss') from t3;
    TO_CHAR(DT_DATE,'MM/DD/YYYYHH2
    02/24/2009 20:23:05
    SQL> Regards,
    Edited by: Walter Fernández on Jul 1, 2009 8:35 PM - Adding example...
    Edited by: Walter Fernández on Jul 1, 2009 8:38 PM
    Edited by: Walter Fernández on Jul 1, 2009 8:41 PM - Fixing some information...

Maybe you are looking for