Stimulate Nested query in OBI

Can i stimulate nested query in OBI?\
Thanks
Bhupendra Gupta

You can also use the obiee logical sql.
Here an example of densification where you can see that you can use subquery.
http://gerardnico.com/weblog/2009/05/12/densification-with-obiee-logical-sql-spare-to-dense-data/
Success
Nico

Similar Messages

  • How to do a Nested Query ?

    I have three Tables Student, Courses, Marks
    Table : Student
    Columns
    StudentID <PK>
    First Name
    Last Name
    Table : Grades
    Columns
    StudentID <FK>
    Grade
    Table : Courses
    Columns
    StudentID <FK>
    CourseID
    CourseDesc
    Now to get all the course descriptions which this particular student is taking based on the StudentID we do something like this :
    SELECT c.courseDesc
    FROM Courses c, Student s
    WHERE s.StudentID = '100'
    AND s.StudentID = c.StudentID
    The above will work
    But If I need to do it in nested query how can I do it : Something like
    SELECT * FROM
    SELECT c.courseDesc
    FROM Courses c, Student s
    AND s.StudentID = c.StudentID
    WHERE s.StudentID = '100'
    Thanks for the help.
    Harsimrat

    oops,try this...
    SELECT * FROM (
    SELECT s.StudentID,c.courseDesc
    FROM Courses c, Student s
    WHERE s.StudentID = c.StudentID)
    WHERE StudentID = '100';
    SQL> select * from
      2  (select e.ename,d.deptno from test_dept d,test_emp e where e.deptno = d.deptno)
      3  where deptno = 10;
    ENAME          DEPTNO
    BLAKE              10
    CLARK              10
    KING               10
    MILLER             10
    SQL>

  • Using nested query to avoid repeated object traversal

    Hi everyone,
    My SQL is still very basic, hopefully this is not a dumb question ;-)
    I have a table with a single spatial column of type SDO_GEOMETRY:
    SQL> desc WITHIN_POINT_DISTANCE_TAB
    Name                                            Null?    Type
    POINT                                                    MDSYS.SDO_GEOMETRYin which I store only single point geometries. I discovered that using the min/max SQL operators to get the combined extend of my points is faster than using SDO_TUNE.EXTEND_OF:
    SQL> select min(e.point.sdo_point.x) min_x, max(e.point.sdo_point.x) max_x, min(e.point.sdo_point.y) min_y, max(e.point.
    sdo_point.y) max_y from WITHIN_POINT_DISTANCE_TAB e;
         MIN_X      MAX_X      MIN_Y      MAX_Y
    -44.700001 737.400024 -23.870001 1094.83008
    Elapsed: 00:00:00.01but it bothers me a bit to repeat e.point.sdo_point 4 times in the above (what can I say, I'm a developer ;-) So I thought I could use a nested query to select all the SDO_POINT_TYPE sdo_point's and refer it using a p alias, and be able to simplify the query to:
    SQL> select min(p.x), min(p.y), max(p.x), max(p.y) from (select t.point.sdo_point from WITHIN_POINT_DISTANCE_TAB t) p;
    select min(p.x), min(p.y), max(p.x), max(p.y) from (select t.point.sdo_point from WITHIN_POINT_DISTANCE_TAB t) p
    ERROR at line 1:
    ORA-00904: "P"."Y": invalid identifierBut obviously this is incorrect, yet I'd like to understand what I'm missing here.
    I posited that maybe the sub-query can't return an object member and needs to return a column, but that doesn't appear to be the case:
    SQL> select min(p.sdo_point.x), min(p.sdo_point.y), max(p.sdo_point.x), max(p.sdo_point.y) from (select t.point from WIT
    HIN_POINT_DISTANCE_TAB t) p;
    select min(p.sdo_point.x), min(p.sdo_point.y), max(p.sdo_point.x), max(p.sdo_point.y) from (select t.point from WITHIN_P
    OINT_DISTANCE_TAB t) p
    ERROR at line 1:
    ORA-00904: "P"."SDO_POINT"."Y": invalid identifierCan someone please explain why the nested query approach fails as written above?
    More generally, is it a bad idea to go for a nested query just for syntactic reasons? Are there performance implications going the nested query route above? (I actually wanted to see the perf. implications experimentally, but since it fails I can't...)
    Any insight would be appreciated. Thanks, --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thank you Peter. I now understand that I need to alias the column in addition to the table (the latter only because I traverse objects which require table aliases).
    SQL> select min(t.p.x), min(t.p.y), max(t.p.x), max(t.p.y) from
      2  (select nt.point.sdo_point p from WITHIN_POINT_DISTANCE_TAB nt) t;
    MIN(T.P.X) MIN(T.P.Y) MAX(T.P.X) MAX(T.P.Y)
    -44.700001 -23.870001 737.400024 1094.83008
    Elapsed: 00:00:00.01Performance-wise it looks similar, but I need to test on a bigger table because it's too fast with 10K points to show differences. Overall it doesn't look that using the nested query syntax makes the query more readable once all pieces to make it work are there.
    Thanks again, --DD
    PS: Just aliasing the column and not the outer table fails:
    SQL> select min(p.x), min(p.y), max(p.x), max(p.y) from (select nt.point.sdo_point p from WITHIN_POINT_DISTANCE_TAB nt);
    select min(p.x), min(p.y), max(p.x), max(p.y) from (select nt.point.sdo_point p from WITHIN_POINT_DISTANCE_TAB nt)
    ERROR at line 1:
    ORA-00904: "P"."Y": invalid identifier

  • Nested query in BPEL JDeveloper

    Hi,
    Can anyone help me with nested query writing in BPEL (JDeveloper)
    the query is :
    SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
    LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
    FROM ITEM_SUPP_COUNTRY_DIM
    WHERE ITEM= &lt;Level1 item&gt;
    AND DIM_OBJECT= (SELECT CASE_NAME FROM ITEM_SUPPLIER WHERE ITEM=&lt;Item&gt; AND PRIMARY_SUPP_IND = &lsquo;Y')
    Please help me with the steps.
    Many thanks

    Hi,
    For the following query:
    SELECT S.STORE, S.STORE_NAME, A.ADD_1, A.ADD_2, A.ADD_3, A.CITY,A.STATE, A.POST, A.COUNTRY_ID, A.CONTACT_PHONE, A.CONTACT_NAME,S.STORE_OPEN_DATE, S.STORE_CLOSE_DATE, S.REMODEL_DATE, S.TRANSFER_ZONE,S.DISTRICT,S.STORE_TYPE
    FROM STORE S, ADDR A
    WHERE S.STORE= #store
    AND to_char(S.STORE) = #keyValue1
    AND A.MODULE = #module
    AND A.ADDR_TYPE = #type
    AND A.PRIMARY_ADDR_IND=#addrType
    the DB adapter shows this xml:
    &lt;?xml version = '1.0' encoding = 'UTF-8'?&gt;
    &lt;xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/WMSStoreDataLookUp" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/WMSStoreDataLookUp" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:element name="WMSStoreDataLookUpInput" type="WMSStoreDataLookUpInput"/&gt;
    &lt;xs:complexType name="WMSStoreDataLookUpInput"&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="store" type="/&gt;<br /><br /> &lt;xs:element name="keyValue1" type="/&gt;
    &lt;xs:element name="module" type="/&gt;<br /><br /> &lt;xs:element name="type" type="/&gt;
    &lt;xs:element name="addrType" type="/&gt;<br /><br /> &lt;/xs:sequence&gt;<br /><br />&lt;/xs:complexType&gt;<br /><br />&lt;xs:element name="WMSStoreDataLookUpOutputCollection" type="WMSStoreDataLookUpOutputCollection" nillable="true"/&gt;<br /><br />&lt;xs:complexType name="WMSStoreDataLookUpOutputCollection"&gt;<br /><br />&lt;xs:sequence&gt;<br /><br />&lt;xs:element name="WMSStoreDataLookUpOutput" type="WMSStoreDataLookUpOutput" minOccurs="0" maxOccurs="unbounded"/&gt;<br /><br />&lt;/xs:sequence&gt;<br /><br />&lt;/xs:complexType&gt;<br /><br />&lt;xs:complexType name="WMSStoreDataLookUpOutput"&gt;<br /><br />&lt;xs:sequence&gt;<br /><br />&lt;xs:element name="S_STORE" type="xs:decimal" nillable="true"/&gt;<br /><br />&lt;xs:element name="S_STORE_NAME" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_ADD_1" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_ADD_2" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_ADD_3" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_CITY" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_STATE" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_POST" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_COUNTRY_ID" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_CONTACT_PHONE" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_CONTACT_NAME" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="S_STORE_OPEN_DATE" type="xs:dateTime" nillable="true"/&gt;<br /><br />&lt;xs:element name="S_STORE_CLOSE_DATE" type="xs:dateTime" nillable="true"/&gt;<br /><br />&lt;xs:element name="S_REMODEL_DATE" type="xs:dateTime" nillable="true"/&gt;<br /><br />&lt;xs:element name="S_TRANSFER_ZONE" type="xs:decimal" nillable="true"/&gt;<br /><br />&lt;xs:element name="S_DISTRICT" type="xs:decimal" nillable="true"/&gt;<br /><br />&lt;xs:element name="S" type="xs:string" nillable="true"/&gt;<br /><br />&lt;xs:element name="A_PRIMARY_ADDR_IND__addrType" type="xs:string" nillable="true"/&gt;<br /><br />&lt;/xs:sequence&gt;<br /><br />&lt;/xs:complexType&gt;<br /><br />&lt;/xs:schema&gt;<br /><br /><br /><br />Please, look at the last few lines of XML and let me know if this is correct..

  • Count(*) with nested query

    Hi,
    I have a question about the count(*) with nested query.
    I have a table T1 with these columns:
    C1 number
    C2 number
    C3 number
    C4 number
    C5 number
    (The type of each column is not relevant for the example.)
    This query:
    select C1, C2, C3, C4
    from T1
    group by C1, C2
    it's not correct becausa C3 and C4 are not columns specified in the GROUP BY expression.
    If if run this query:
    select count(*)
    from (select C1, C2, C3, C4
    from T1
    group by C1, C2)
    I haven't an error message (the result is correctly the number of records).
    Why?
    Thanks.
    Best regards,
    Luca

    Because you are just selecting count(*) and none of the columns from the subquery, Oracle is optimising it by ignoring the selected columns and just running the sub query with the group by columns. I know it seems odd, but if you take a basic example:
    SQL> ed
    Wrote file afiedt.buf
      1  select count(*)
      2  from (select empno, sal, mgr, deptno
      3  from emp
      4* group by deptno)
    SQL> /
      COUNT(*)
             3... all columns but deptno are ignored
    ... but if you include one of the other columns, even if you group by that column...
    SQL> ed
    Wrote file afiedt.buf
      1  select count(*), empno
      2  from (select empno, sal, mgr, deptno
      3  from emp
      4  group by deptno)
      5* group by empno
    SQL> /
    group by empno
    ERROR at line 5:
    ORA-00979: not a GROUP BY expression
    SQL>... the error returns, because you're forcing oracle to include the column in the subquery.

  • Error in making left outer join to a nested query

    i am writing this query getting error here i am using nested query with that i am making join it is giving error
    SQL
    SELECT
    * FROM IVItem INNER JOIN
    IVPackSize_Mst ON IVItem.PackSizeID = IVPackSize_Mst.Id
    left outer join IvItemGenericLink on IvItemGenericLink.itemID=IVItem.Id
    Select GenericId from
    IvItemGenericLink where ItemID=IVItem.Id and rownum <=1
    )x
    and x on IvItemGenericLink.GenericId=x.GenericId;
    Error report:
    SQL Error: ORA-00936: missing expression
    00936. 00000 - "missing expression"
    *Cause:   
    *Action:
    give me and suggestion

    i am using left outer join at virtual table say x your gave me its equivalent
    EXISTS (SELECT 1 FROM IvItemGenericLink G
    WHERE G.ITEMID =V.ID
    AND G.GenericId = L.GenericId)-----its i guess inner join
    i am not confirmed that why iam asking this i guess i have to use this
    as i use keyword inner join for inner join and for left join i use
    left outer join
    EXISTS (SELECT 1 FROM IvItemGenericLink G
    WHERE G.ITEMID =V.ID
    AND G.GenericId(+) = L.GenericId)-----its i guess left outer join
    left outer join
    Select GenericId from
    IvItemGenericLink where ItemID=IVItem.Id and rownum <=1
    )*x*
    IvItemGenericLink.GenericId=x.GenericId
    -------------------Statement U Gave in this--------------------------------------------------------------------------
    SELECT *
    FROM IVITEM V, IVPACKSIZE_MST M , IVITEMGENERICLINK L,
    WHERE V.PACKSIZEID = M.ID
    AND V.ID = L.ITEMID (+)
    AND EXISTS (SELECT 1 FROM IvItemGenericLink G
    WHERE G.ITEMID =V.ID
    AND G.GenericId = L.GenericId)
    -------------------Statement U Gave in this--------------------------------------------------------------------------
    is this equivalent to left outer join
    *AND EXISTS (
    SELECT 1 FROM IvItemGenericLink G*
    WHERE G.ITEMID =V.ID
    *AND G.GenericId = L.GenericId
    please tell me this in this regard

  • Nested query / Rank in ODI 10g?

    How can be an nested query with analytical function (RANK() OVER) can be implemented in ODI 10g without using an external view?
    SELECT field1, field2, field3, field4, field5, field6, field7
    FROM
             (SELECT
              RANK() OVER (PARTITION BY  table1.field1, table1.field2, table1.field3 ORDER BY table1.field4 , table1.field5) alias_rank,
              field1, field2, field3, field4, field5, field6, field7
                    FROM table1
              ) subset_alias   
    WHERE subset_alias.alias_rank=10)

    You should get your answers from here
    http://www.business-intelligence-quotient.com/?tag=oracle-data-integrator-subqueries

  • Nested query loops

    If you have nested query loops (<cfloop
    query="qA"><cfloop query="qB"> qA vars in here
    </cfloop></cfloop>), is it possible to carry the vars
    from qA into the qB loop.
    Not sure if this makes sense, but any time i have nested
    query loops, i can't access the outer loops vars.

    Use a different index variable for each loop. Use complete
    syntax, ie queryname.fieldname[rownumber] for each query
    variable.

  • Executing nested query contains ORDER BY:Help Needed

    I have a database in ORACLE 8.0 enterprise
    edition in HP-UX. I am trying to execute the following query
    "select * from ( select * from temptable order by value desc) where rownum < 5"
    and I am getting the following error
    "missing right parenthesis"
    This syntax is given in the Oracle user guide
    under sql commands section and it is not
    working.
    Similar query is working on Oracle 8.1 running on Win NT.
    Does any body throw some light.
    Thanks in advance
    -raj

    Your query works fine in Oracle 8i:
    SELECT *
    FROM (SELECT *
    FROM temptable
    ORDER BY value DESC)
    WHERE ROWNUM < 5;
    However, prior to Oracle 8i, in Oracle 8.0, it is not allowed to have an ORDER BY clause within a nested query. So, in Oracle 8.0, a query like the above cannot work. However, the following, with the ORDER BY clause in the outer query will work:
    SELECT *
    FROM temptable a
    WHERE 5 >=
    (SELECT COUNT (*) + 1
    FROM temptable b
    WHERE b.value > a.value)
    ORDER BY a.value DESC;
    null

  • Nested query in FROM clause causes 'SQL Command not properly ended' error

    SELECT sj.job_id AS job_id, 'STATUS_AWAITING_PREPARATION' AS job_status, sjr.email_sys_attach_filename AS attach_filename, sje.emailaddr as emailaddr_lastsentto
                        FROM arsnd_jobs sj, (SELECT emailaddr from ARSND_JOB_EMAILS where job_id=sj.job_id AND ROW_NUM=1) as SJE, ARSND_JOB_QUEUE sjq,ARSND_JOB_RECIPIENTS sjr
                        WHERE sj.job_id=sjq.job_id and sj.job_id=sjr.job_id
                        AND sjq.PROCESSING_STATE=0
                        ORDER BY sj.created
    I don't see anything wrong with the above query, it fails with 'SQL Command not properly ended'.
    If I remove the usage of the nested query in the FROM clause, then it doesn't give that error. Please advice what I'm doing wrong.

    Pls try
    SELECT sj.job_id AS job_id, 'STATUS_AWAITING_PREPARATION' AS job_status, sjr.email_sys_attach_filename AS attach_filename, sje.emailaddr as emailaddr_lastsentto
    FROM arsnd_jobs sj, (SELECT emailaddr from ARSND_JOB_EMAILS where job_id=sj.job_id AND ROW_NUM=1) SJE, ARSND_JOB_QUEUE sjq,ARSND_JOB_RECIPIENTS sjr
    WHERE sj.job_id=sjq.job_id and sj.job_id=sjr.job_id
    AND sjq.PROCESSING_STATE=0
    ORDER BY sj.created
    I have removed the 'as' clause you used for alias of the subquery. It should work fine now.....

  • What is a Nested Query

    Hi,
    What is a nested query? Can anyone give me an example of how to create a nested query? Please expain me in detail with an example?
    Thanks
    Rani

    Hi,
    nested query is like one querys result is used as a input to second query.it is sort of a replacement path char variable filled by a query result is used for a char restriction in one query. Restriction is somewhat like Top N. Returned set of values is used for a restriction in the 2nd query.
    Assume that in Query X, a characteristic A returns values 1,2,3. (Master data of A may be 1,2,3,4.....)
    In another Query Y, you want to restrict char A to only those values that are returned in Query X, in our example its 1,2 & 3. To achieve this, you will create a replacement path variable on char A in Query Y, in the process it will ask you to give the query name, which will be Query X
    For nested "If "condition in Bex Formula's:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/23/17f13a2f160f28e10000000a114084/frameset.htm
    Regards
    CSM Reddy

  • Nested query example

    what is the diference between char dat type and n char dara type.
    what is nested query and give me one example

    what is the diference between char dat type and n char dara type.They have in common that you'd rather want to use (N)VARCHAR2 instead....
    (Totally unrelated) example:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6349391411093#tom2648420300346089448
    Quoting last sentence:
    "sigh, wish they would have used a varchar.... if you do the above with a as a varchar2 instead of a stupid char (no one uses char, not if they know any better).... "
    Regarding nested table:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8135488196597

  • Optimising a nested query

    I am trying to rewrite the following query without using a
    nested query:
    select date_r,value
    from indices
    where date_r = (select max(date_r) from indices)
    Is there any way to do this?
    Thanks in advance,
    Shefali

    It depends what version of Oracle you are on, I suppose.
    You could do ..
    select date_r,value
    from (select date_r,value from indices order by date_r desc)
    where rownum = 1
    With an index on date_r (called idx_date_r) you could do ...
    select /*+ index_desc(indices idx_date_r) */ date_r,value
    from indices where rownum = 1

  • Nested query value used as comparison in second nested query

    Hi,
    What would be the best way of writing the following:
    I have a simple SELECT statement which includes two nested queries used to get the start and end dates from two different tables (if the first date from the first table and the second from a different table), there is not real direct relationship between
    those two seperate tables.  However the result of the first date nested select would determine part of the WHERE statement in the second nested statement.
    I need a way of using the value returned as a part of first nested select in the where statement of the second.
    I know exactly how to do this using something like ASP.NET C# but that involved running them as seperate queries and storing the values in variables before running a new statement for example and I would prefer to run a single query with the nested selects
    and get the results as required.
    Can anyone point me in the right direction of the best way of running this kind of thing?
    Cheers for any replies!

    Hello,
    Please provide DML for the tables, some sample data and the expected result. Just with your description we could only guess.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Cursor with nested query in stored procedure problem

    Hello
    I'm trying to declare the folowing (example) cursor in a stored procedure in Oracle 8i:
    CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    The nested part "(SELECT d.DUMMY FROM dual)" is not alowed, while the same query runs outside the stored procedure. Can someone explain why this is not alowed and how to solve the problem whitout rewriting the query?
    Tom

    When i run the same code in SQL plus:
    SQL> declare
    2 CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    3 begin
    4 null;
    5 end;
    6 /
    CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    FOUT in regel 2:
    .ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + mod not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string>
    ORA-06550: line 2, column 66:
    PLS-00103: Encountered the symbol "FROM" when expecting one of the following:
    ; return returning and or
    Different versions of Oracle?

Maybe you are looking for

  • Making constraints on a symbol...

    I'm new here and I'm taking a class on Director. Unfortunately, my teacher does not know how to do much himself which is leaving me to come here and seek advice. Flash is a better option for what I'm looking for and Director is moved out anyway. Plea

  • 24" Cinema Display (LED) with 2008 Mac Pro

    My 23" Cinema Display monitor is beginning to show signs of aging, having been used with two Mac Pros and a G5. I'd like to upgrade the monitor to a 24" LED Cinema Display, but the 2008 Mac Pro doesn't have the mini-DVI port. Is there any upgrade pat

  • Can't Drag and Drop in iMovie '11

    I just started using this software, and for some reason it won't let me drag and drop video files to my project. I started with flv, then mov, and even mp4. None of them would work. I could import mp4 the long way by going through the menus, but I wo

  • Suddenly "Fatal error during GPU init" during boot - radeon

    Hi, after a rather abrupt shutdown my system doesn't boot correctly anymore. I have an Asus laptop with an ATI radeon HD 2400 (so the sticker on the laptop says - I'm not really a hardware guy) Before: While booting, the kernel/console output had big

  • Problem playing music after downloading ios5

    I downloaded the new ios5 software for my iphone 4 last week, and everytime i go into play my music, none of my songs play they just stay on 0:00 even though they are 'playing' and the pause butotn comes up if i put it in shuffle mode the songs do th