SUB QUERIES HELP

Question =
show name,function,officename and salary from all employee with the same function as employee 'PIETERS' or <= salary then 'SANDERS'
Tabs are; Employees (keys, emplnr and officenr), OFFICE (key officenr)
Dus someone have a suggestion how to manage this query??
Gtz Ismoo

Something like this ?
TEST@db102 SQL> select * from emp order by job;
          EMPNO ENAME      JOB                   MGR HIREDATE              SAL            COMM          DEPTNO
           7788 SCOTT      ANALYST              7566 09-DEC-82            3000                              20
           7902 FORD       ANALYST              7566 03-DEC-81            3000                              20
           7369 SMITH      CLERK                7902 17-DEC-80             800                              20
           7934 MILLER     CLERK                7782 23-JAN-82            1300                              10
           7876 ADAMS      CLERK                7788 12-JAN-83            1100                              20
           7900 JAMES      CLERK                7698 03-DEC-81             950                              30
           7782 CLARK      MANAGER              7839 09-JUN-81            2450                              10
           7698 BLAKE      MANAGER              7839 01-MAY-81            2850                              30
           7566 JONES      MANAGER              7839 02-APR-81            2975                              20
           7839 KING       PRESIDENT                 17-NOV-81            5000                              10
           7844 TURNER     SALESMAN             7698 08-SEP-81            1500               0              30
           7499 ALLEN      SALESMAN             7698 20-FEB-81            1700             300              30
           7521 WARD       SALESMAN             7698 22-FEB-81            1250             500              30
           7654 MARTIN     SALESMAN             7698 28-SEP-81            1250            1400              30
14 rows selected.
TEST@db102 SQL> select ename, job, dname, sal
  2  from emp e, dept d
  3  where job = (select job from emp where ename = 'MILLER')
  4  and e.deptno = d.deptno
  5  and ename != 'MILLER'
  6  union
  7  select ename, job, dname, sal
  8  from emp e, dept d
  9  where sal <= (select sal from emp where ename = 'TURNER')
10  and e.deptno = d.deptno
11  and ename != 'TURNER'
12  order by 1;
ENAME      JOB       DNAME                      SAL
ADAMS      CLERK     RESEARCH                  1100
JAMES      CLERK     SALES                      950
MARTIN     SALESMAN  SALES                     1250
MILLER     CLERK     ACCOUNTING                1300
SMITH      CLERK     RESEARCH                   800
WARD       SALESMAN  SALES                     1250
6 rows selected.
TEST@db102 SQL>                                                                                 

Similar Messages

  • Sub queries

    i have a longish query which runs correctly in Oracle 8i Lite thro SQL Plus but does not run when using JDBC.
    The query has multiple subqueries and it looks like
    delete from node_initial_values d where d.node_id in (select c.node_id from node_master c where c.node_id=d.node_id and c.node_id in (select e.node_id from network_design e where c.node_id=e.node_id and e.network_id in (select b.network_id from network_master b where e.network_id=b.network_id and b.network_id in (select g.network_id from output_network_scenario g where g.network_id=b.network_id and g.output_network_master_id in (select a.output_network_master_id from output_network_master a where a.output_name= 'network three')))));
    assume all the tables exist with correct data. the above query works perfectly well in SQL*plus but when i use
    the following code i get an error
    PreparedStatement deleteNodeInitialValuesPst=getConn.prepareStatement("delete from node_initial_values d where .... a where a.output_name= ?)))))");
    deleteNodeInitialValuesPst.setString(1,"network three");
    deleteNodeInitialValuesPst.executeUpdate();
    getConn.commit();
    ... rest of the code
    the error code oracle 8i lite gives is
    java.sql.SQLException: [POL-4200] bad action for transaction operation
    would really appreciate any help in this regard...
    specifically can anyone tell me if prepared statement is the correct function to use here...
    thanks

    I made the following changes:
    changes to the code, new code mentioned below
    changed the database to oracle 8i enterprise edition running on NT.
    new code now is
    // connetion parameter and other code here
    String deleteNodeInitialValuesStr=
    "delete from node_initial_values d where d.node_id in (select c.node_id from node_master c where c.node_id=d.node_id and c.node_id in (select e.node_id from network_design e where c.node_id=e.node_id and e.network_id in (select b.network_id from network_master b where e.network_id=b.network_id and b.network_id in (select g.network_id from output_network_scenario g where g.network_id=b.network_id and g.output_network_master_id in (select a.output_network_master_id from output_network_master a where a.output_name='"+nextElementStr+"')))))";
    Statement deleteNodeInitialValuesSt=getConn.createStatement();
              deleteNodeInitialValuesSt.executeQuery(deleteNodeInitialValuesStr);
    getConn.commit();
    } // end try
    catch(SQLException ex) {
         while(ex !=null){
    out.println("Java SQL Exception: " + ex.getMessage()+"<br>");
    out.println("Vendor error code: " + ex.getErrorCode()+ "<br>");
    out.println("SQL State: " + ex.getSQLState() + "<br>");
    ex=ex.getNextException();
    } // end while
    } // end catch
    // more code here
    the output i get is
    Java SQL Exception: 202
    Vendor error code: 0
    SQL State: null
    I turned off getConn.commit(), but the error code remains the same. is there an alternative to the sub queries above. where can i get the meaning of the error codes thrown by the exception ?
    thanks

  • How can I create "Sub Queries" in a select statement?

    Hi all,
    I need to create reports, which are not based on a single table but on several "sub-queries".
    This would be the code, but I don't know how to solve that problem...
    SELECT OGBI.*
    FROM
    (((select "OSSRALL"."FORECAST_OWNER", sum
    ("OSSRALL"."TOTAL_OPPORTUNITY_AMOUNT")
    from "#OWNER#"."OSSRALL" "OSSRALL",
    "#OWNER#"."TEAM_MAIN" "TEAM_MAIN",
    "#OWNER#"."MA_MAIN" "MA_MAIN"
    group by "OSSRALL"."FORECAST_OWNER")OGBI.APPSME1)
    where "OSSRALL"."OPP_CLASS" = (EX_OTHERS)),
    -- more are following
    "#OWNER#"."OSSRALL" "OSSRALL",
    "#OWNER#"."TEAM_MAIN" "TEAM_MAIN",
    "#OWNER#"."MA_MAIN" "MA_MAIN"
    WHERE
    ("MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"||' Mr'
    like "OSSRALL"."FORECAST_OWNER" or
    "MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"||' Mrs'
    like "OSSRALL"."FORECAST_OWNER" or
    "MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"
    like "OSSRALL"."FORECAST_OWNER") and
    ("OSSRALL"."SALES_GROUP"="TEAM_MAIN"."NAME") and
    ("MA_MAIN"."MA_ID"=:P17_VB1)
    thx a lot for your help.
    kind regards Jan
    Message was edited by:
    Jan Rabe

    Jan
    Please can you post the full select statement and the DDL to create the tables? Or, provide someone access to the app on the Oracle server.
    We can probably make these much more readable using table aliases and removing the owner unless you are doing this across schemas or via a wizard?
    It looks like you are missing joins in your query - is this what you mean by subqueries? It is a good idea to move the join up before the WHERE clause if you can as this makes the query easier to manage.
    Phil

  • Using Sub Queries in OBIEE

    Hi,
    I am new to the OBIEE world and was wondering how we can work with sub queries. I have the following problem.
    I have a table namely XYZ in which we have "effective date" and "Amount". In the answers section have have filter out the data for the month of 01-Nov-08 to 30-Nov-08 which shows the total cash amount for that month. Now the problem is that I need to use the same "effective date" and "Amount" to get the opening balance which is calculated by Sum(Amount) where "effective date" < 01-Nov-2008. If i try to do this I do not see any results as the data gets filtered out. Can someone please help me on this?
    Thanks

    Hi,
    In column formula put column level filter like this FILTER("Facts Revenue".Revenue USING (Time."Day Date" < date '2006-10-09'))
    Regards
    Naresh

  • [8i] Question on hints when there are sub-queries / in-line views

    I've noticed that when I query my database, it seems to default to the RBO rather than the CBO. I've been troubleshooting a huge query that takes a good half an hour to run... First, when I saw it was using the RBO, I added the /*+ CHOOSE */ hint (to my top-level SELECT), but that didn't help much. So, I decided to go through all the sub-queries / in-line views. One of my sub-queries, with no hint, takes 2.5 min. to run. I added the /*+ CHOOSE */ hint to it, and it only took 20 seconds.
    My question is, if I add a hint to the top-level SELECT, does it get applied to every sub-query, or do I need to put that hint in every sub-query as well?

    I just tested this out... I ran a portion of my query with a couple of sub-queries, and the first time, I just put the CHOOSE hint in my top level SELECT statement. The second time, I put it in both the top level and in the SELECT statement of one of the sub-queries. The explain plans are too long to post, but these are the statistics:
    1st run (only 1 hint):
    Statistics
              0  recursive calls
           2345  db block gets
         885019  consistent gets
            681  physical reads
              0  redo size
         185226  bytes sent via SQL*Net to client
          11371  bytes received via SQL*Net from client
            160  SQL*Net roundtrips to/from client
              0  sorts (memory)
              1  sorts (disk)
           2371  rows processed
    timing for: query_timer
    Elapsed: 00:00:29.092nd run: (2 hints)
    Statistics
             14  recursive calls
           2345  db block gets
         885035  consistent gets
            620  physical reads
              0  redo size
         185226  bytes sent via SQL*Net to client
          11371  bytes received via SQL*Net from client
            160  SQL*Net roundtrips to/from client
           4498  sorts (memory)
              1  sorts (disk)
           2371  rows processed
    timing for: query_timer
    Elapsed: 00:00:56.03It looks to me like the first one ran more efficiently. Can someone explain this to me? I figured that putting hints in the sub-queries would, at worst, do nothing, and at best, improve the performance, but it looks like the opposite happened.
    Edited by: user11033437 on Aug 12, 2010 11:17 AM (fixed some info/copy paste error)

  • Usage of joins & sub-queries

    can anyone help me know the situation when to use the joins and sub-queries manipulating with more than one tables???? which among the two is faster normally???? because we can do same process using both these options.....

    Balasubramaniam:
    I think I can be so bold to say that, in general, joins are faster than sub-queries. But there are a lot of variables - data types, row/table sizes, indexes.
    Try it and compare, with your production data.
    Tom Best

  • A Single query with out the sub-queries

    I am using My-SQL as my back-end and it doesnot support the
    Sub-Queries. i have my table given below
    UserID..UserName..ParentUserID
    1........Admin...........0
    2........Sales...........1
    3........Sourcing........1
    4........SalesHead.......2
    5........SourcingHead....3
    6........SalesExec.......4
    7........SourExec........5
    The table contains heirarchy of users. The top most users
    has the ParentUserID as 0. and the remaining has their own ParentUserID
    I want to get the complete heirarchy of a given user in single ResultSet.
    It should be done without using sub-queries. but all joins can be used.
    e.g.
    if i say userid is 2 i should get following output:
    Sales - > SalesHead -> SalesExec->......
    Can any body please help me out!
    Sridhar.

    Hi Sridhar,
    You can use recursive method. Make a method as follows :
    public String getChildren(int UserID)
         String temp = "";
         Connection con = DriverManager.getConnection("","","");
         Statement st = con.createStatement();
         ResultSet rs = statement.executeQuery("select UserID from MyUsers where ParentUserID = " + UserID);
         while(rs.next())
              temp += " [ ";
              if(temp.equals(""))
                   temp += getChildren(rs(0));
              else
                   temp += " -> " + getChildren(rs(0));
              temp += " ] ";
         return temp;
    then call his method by providing any UserID to it and it will return you a string containing complete hierarchy in the following format :
    AAA -> BBB -> CCC -> DDD
    I hope it will help you.
    regards,
    Humayun

  • In which sequence are queries and sub-queries executed by the SQL Engine

    In which sequence are queries and sub-queries executed by the SQL Engine?
    Which is correct ?
    a. primary query -> sub query -> sub sub query and so on
    b. sub sub query -> sub query -> prime query
    c. the whole query is interpreted at one time
    d. there is no fixed sequence of interpretation, the query parser takes a decision on the fly

    In which sequence are queries and sub-queries executed by the SQL Engine?
    Which is correct ?
    a. primary query -> sub query -> sub sub query and so on
    b. sub sub query -> sub query -> prime query
    c. the whole query is interpreted at one time
    d. there is no fixed sequence of interpretation, the query parser takes a decision on the fly
    Hi, below may help you understanding simple subquery & correlated subquery
    refer :
    http://sqlmag.com/t-sql/t-sql-starters-simple-and-correlated-subqueries
    a) if it is correlated subquery
     A correlated subquery is one that depends on a value in the outer query. In programming terms, you pass the subroutine an argument, then the subroutine evaluates the query and returns a result. You move on to the next record and repeat the process. The
    net effect is that the subquery runs once for every row in the main query; this situation is inefficient.
                                  A possible alternative is to rewrite the correlated subquery as a join. However,
    some situations require a subquery. Eg- IN(with outer table refernce)
    so  main query -> subquery
    b) if it is simple subquery
    A subquery is a query that SQL Server must evaluate before it can process the main query, Eg- IN(with out outer table refernce)
    so subquery-> main query
    c) correlated query interpreted row by row with subquery, while subquery is interpreted at one time(outer table and inner table)
    d) in most case it depends on the whether it is correlated subquery or simple subquery
    Thanks
    Saravana Kumar C

  • Sub queries in CR 11

    Post Author: pranathi20
    CA Forum: Data Connectivity and SQL
    Hi All,
    Can someone help me with the below SQL query? I am not sure how to have the sub query in CR
    SELECT   x.created_on, x.ssn, x.age  ,        max(DECODE(x.rn,1,x.nlsi_answer)) BIO001  ,        max(DECODE(x.rn,4,x.nlsi_answer)) BIO116  ,    x.nlsipvsc
      FROM    (SELECT nlsiview.created_on created_on           ,      nlsiview.ssn     ssn           ,      nlsiview.age     age           ,      nlsiview.answer  nlsi_answer           ,      ROW_NUMBER() OVER (PARTITION BY nlsiview.created_on, nlsiview.ssn                                     ORDER BY     NULL) rn           FROM   nlsiview           ) x  GROUP BY x.created_on, x.ssn, x.age    ORDER BY x.created_on, x.ssn  /

    I Assume that you have done creating required OCE, and familiar with the single table query process. You can create sub queries using the Custom SQL feature, which is located under view menu->custom SQL. Please note that the query data model must have at least one table to use this feature.
    Here are the steps to create sub query.
    1. select the main table from table catalog list
    2. select the required columns from table and right click " add selected items" to request section.
    3. go to View menu - > custom SQL
    4. you will see a section which is editable enter all your where clause and sub query section and then process.
    Let me know if you need any detail information.

  • IN clause with ORDER BY clause in sub-queries

    Hello,
    We generate dynamic queries with the following statement pattern (could be many union/intersect sub-queries):
    select my_col
    from my_table
    where my_col IN
    select table_2.my_col , x_col from table_2 where x_col > 10
    UNION
    select table_3.my_col , y_col from table_3 where y_col > 20
    INTERSECT
    select table_4.my_col , z_col from table_4 where z_col is between 30 and 50
    I know that I can do just the sub-queries w/ an ORDER BY clause as follows (as long as the 2nd parameter in the select stmts are of the same type):
    select table_2.my_col , x_col from table_2 where x_col > 10
    UNION
    select table_3.my_col , y_col from table_3 where y_col > 20
    INTERSECT
    select table_4.my_col , z_col from table_4 where z_col is between 30 and 50
    order by 2 desc
    But my questions are:
    1. What is (if there is) the syntax that will ensure that the result set order will be that of the ordering of the sub-queries?
    Or does my SQL stmt have to have syntactically (but not semantically) change to achieve this?
    Thanks,
    Jim

    Randolf Geist wrote:
    just a minor doubt - I think it is not officially supported to have separate ORDER BYs in a compound query with set operators (e.g. UNION / UNION ALL subsets). Of course one could use inline views with NO_MERGE + NO_ELIMINATE_OBY hints, but I think the only officially supported approach is to use a single, final ORDER BY (that needs to use positional notation as far as I remember).
    Randolf,
    You're right, of course, about the separate "order by" clauses.
    Interestingly the following type of thing does work though (in 10.2.0.3, at least):
    with v1 as (
        select * from t1 where col1 = 'ABC' order by col2
    v2 as (
        select * from t1 where col1 = 'DEF' order by col2
    select * from v1
    union all
    select * from v2
    ;A quick check the execution plan suggsts that Oracle appears to be convering this to the following - even though its technically not acceptable in normal circumstances:
    select * from t1 where col1 = 'ABC' order by col2
    union all
    select * from t1 where col1 = 'DEF' order by col2
    ;Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • With clause vs sub-queries

    db and dev 10g rel2 , hi all,
    i am trying to learn the "WITH CLAUSE" , and i do not see any difference between using it and using sub-queries .
    when i searched for this , i found that the with clause is used when You need to reference the subquery block multiple places in the query by specifying the query name , but i can not imagine an example for doing so .
    if you could provide me with an example please ? and telling me about another situations in which i could need using the "with clause" if any ?
    thanks

    >
    db and dev 10g rel2 , hi all,
    i am trying to learn the "WITH CLAUSE" , and i do not see any difference between using it and using sub-queries .
    when i searched for this , i found that the with clause is used when You need to reference the subquery block multiple places in the query by specifying the query name , but i can not imagine an example for doing so .
    if you could provide me with an example please ? and telling me about another situations in which i could need using the "with clause" if any ?
    >
    It isn't just about referencing a subquery multiple times. There are other advantages to using 'common table expressions'/'subquery factoring' also.
    Take a look at the example below. It first defines 'dept_costs' as a query block, then defines 'avg_cost' as a new query block and it references the first query block.
    Then the actual query references both query blocks just as if they are tables. And, in fact, in some circumstances Oracle will actually materialize them AS temporary tables.
    Look at how easy it is to understand the entire statement. You can focus first on the 'dept_costs' query block WITHOUT having to look at anything else. That is because the query block is self-contained; you are defining a result set. There is no 'join' or connection to any other part of the statement.
    It is easy for a developer, and for Oracle, to understand what is needed for that one piece.
    Next you can focus entirely on the 'avg_cost' query block. Since it uses the first query block just as if it were a table you can treat it as a table. That means you do NOT even need to look at the first query block to understand what the second query block is doing.
    Same with the actual query. You can analyze it by treating the two query blocks just as if they were other tables.
    Even better you can test the first query block by itself in sql*plus or other tool to confirm that it works and you can create an execution plan for it to make sure it will use an appropriate index. You can also then test the first and second query blocks together to make sure THEY have a proper execution plan.
    Then when you test then entire statement you already know that the query blocks work correctly.
    Try to do THAT with a query that uses nested sub-queries.
    Sure - you could write a set of nested sub-queries to accomplish the same thing (Oracle will sometimes rewrite your query that way itself) but it becomes one big query and the individual pieces are not nearly as easy to see, analyze or understand.
    It can be difficult if not impossible to extract a nested query in order to test it even to just try to get the syntax working. And when you do extract it you will often be testing something that isn't quite exactly the same as when i t was nested.
    So: easier to understand, easier to write and test (especially for new developers) as well as easier to use multiple times without having to duplicate it.
    >
    subquery_factoring_clause
    The WITH query_name clause lets you assign a name to a subquery block. You can then reference the subquery block multiple places in the query by specifying the query name. Oracle Database optimizes the query by treating the query name as either an inline view or as a temporary table.
    >
    The SQL Language doc has an example.
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10002.htm#i2129904
    >
    Subquery Factoring: Example The following statement creates the query names dept_costs and avg_cost for the initial query block containing a join, and then uses the query names in the body of the main query.
    WITH
    dept_costs AS (
    SELECT department_name, SUM(salary) dept_total
    FROM employees e, departments d
    WHERE e.department_id = d.department_id
    GROUP BY department_name),
    avg_cost AS (
    SELECT SUM(dept_total)/COUNT(*) avg
    FROM dept_costs)
    SELECT * FROM dept_costs
    WHERE dept_total >
    (SELECT avg FROM avg_cost)
    ORDER BY department_name;
    DEPARTMENT_NAME DEPT_TOTAL
    Sales 313800
    Shipping 156400

  • Sub Queries VS  Variables in the Query

    #1
    for i in ( select a.name,b.price,a.date from
    list a, sales b
    where a.header_id=b.header_id
    and b.date_key= (select date_key from date_tab
    where date_field=trunc(sydate))
    loop
    end loop.
    #2
    select date_key into v_date_key from date_tab where date_field=trunc(sydate);
    for i in ( select a.name,b.price,a.date from
    list a, sales b
    where a.header_id=b.header_id
    and b.date_key= v_date_key)
    loop
    end loop.
    Please advice me , using the sub queries(#1) or substution variable (#2) in the condition part will improve the performance of the query.
    Thanks

    Most likely, there won't be a difference in performance.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Can anyone tell me WHY Oracle won't allow sub-queries in outer joins?

    Hi,
    I've recently been tasked with converting a series of InterBase dbs to Oracle.
    Many of the queries in the InterBase dbs use sub-queries in outer joins. Oracle won't countenance this (01799 - a column may not be outer-joined to a subquery).
    I can get around it using functions but WHY won't Oracle allow this?
    SQL Server allows it, InterBase allows it (I don't know about ANSI SQL) but it seems to be a common enough technique...
    I'm just curious (and also a little frustrated!).
    Thanks in advance,,,

    Hi,
    >>Oracle treat an empty string as a NULL
    Well, you same answer your question. Because it is empty
    SGMS@ORACLE10> create table tab (cod number, name varchar2(1));
    Table created.
    SGMS@ORACLE10> insert into tab values (1,'');
    1 row created.
    SGMS@ORACLE10> insert into tab values (2,' ');
    1 row created.
    SGMS@ORACLE10> commit;
    SGMS@ORACLE10> select cod,dump(name) from tab;
           COD DUMP(NAME)
             1 NULL
             2 Typ=1 Len=1: 32
    SGMS@ORACLE10> select * from tab where name is null;
           COD NAME
             1Cheers
    If you talking about language tools, for example PHP treat empty string <> of NULL values. e.g: functions like is_empty() and is_null()
    Message was edited by:
    Legatti

  • Disco Plus and Sub-queries in conditions

    Hi,
    I have a strange behaviour for a report using a sub-query in the condition:
    in Desktop Edition and Viewer it works just fine, in Plus no data is returned.
    I am using Discoverer 9.0.2.
    The condition was created from the Desktop using an existing datasheet, both data sheets using the same parameter.
    I examined the SQL code from Plus and the statement returns data and the sheet with the sub-query also returns data - nevertheless the report doesn't return any data.
    As far as I know you cannot create or modify sub-queries in conditions with PLus - but at least the report should work?! Does anyone know where the problem could be?
    Thank you very much in advance!
    Alex

    Trying to create a sub-query in discoverer...
    Using Desktop (9.04 and 10.1.2), the option "Create Sub-Query" is not available in the condition values. Feel like I'm missing something - has anyone come across this before?
    I assume sub-queries should be possible/supported in Plus 10.1.2 (although it's not in the user guide). If so, the Create Sub-Query option is not available like in Desktop. If not, why not - seeing as it's basic sql commonly used in reporting?
    Thanks!

  • Can you pass parameters with sub queries

    I have created a Custom folder within a Business Area using a sql query that has multi sub queries. I need to be able to pass date parameters at the top level and at each sub query levels. Is this possible, or how can it be done in Discoverer?
    I have attached an example of the query below.
    select T.title_type_code, T.title_number
    from title_trans T
    where T.title_type_code in ( 'A', 'AC', 'AN','AS','EL', 'ERL','SEL', 'MC', 'MCN', 'MCC', 'MCS', 'ML', 'MLN', 'MLC', 'MLS')
    and T.trans_type_code = 'APPL'
    and trunc(T.effective_date) between to_date('&start_date','DD/MM/YYYY') and to_date('&end_date','DD/MM/YYYY')
    and exists
    (select *
    from title_land_status L     
    where T.title_type_code = L.title_type_code
    and T.title_number = L.title_number
    and L.trans_type_code in ('APPL', 'FLS', 'AVAR')
    --FREEHOLD LAND
    and L.land_status_id in ('15')
    and L.date_completed = (select MAX(L.date_completed)
    from title_land_status L
    where T.title_type_code = L.title_type_code
    and T.title_number = L.title_number
    and trunc(L.date_completed) <= to_date('&end_date','DD/MM/YYYY')
    and L.trans_type_code in ('APPL', 'FLS', 'AVAR')))
    and not exists
    (select *
    from title_land_status L     
    where T.title_type_code = L.title_type_code
    and T.title_number = L.title_number
    and L.trans_type_code in ('APPL', 'FLS', 'AVAR')
    --AB fREEHOLD LAND - NLC, CLC, TLC, ALC
    and L.land_status_id in ('3', '4', '5', '6')
    and L.date_completed = (select MAX(L.date_completed)
    from title_land_status L
    where T.title_type_code = L.title_type_code
    and T.title_number = L.title_number
    and trunc(L.date_completed) <= to_date('&end_date','DD/MM/YYYY')
    and L.trans_type_code in ('APPL', 'FLS', 'AVAR')))
    and not exists
    (select * from title TIT
    where T.title_type_code = TIT.title_type_code
    and T.title_number = TIT.title_number
    and TIT.purpose = 'EMPC')
    order by T.title_type_code;

    Ok,
    I just tried that and it still doesn't pass anything to the prompt.
    I changed the prompt to an edit field and I made the following weblink but when i click the link from an account it doesn't put anything in the prompt and all data for all accounts is shown.
    This is the URL maybe I messed something up...
    https://secure-ausomx###.crmondemand.com/OnDemand/user/Dashboard?OMTHD=ShowDashboard&OMTGT=ReportIFrame&SelDashboardFrm.Dashboard Type=%2fshared%2fCompany_########_Shared_Folder%2f_portal%2f360+Report&Option=rfd&Action=Navigate&P0=1&P1=eq&P2=Account."Account Name"&P3=%%%Name%%%
    thanks

Maybe you are looking for

  • No photos in gallery but still 2.6GB taken from memory to photos

    I deleted all my photos in my iphone and in itunes I cheack out the V from photos sync (anyway i never sync any photos from itunes before) and still when i cheack on itunes and in the iphone it self how my memory is spillted 2.6 Gb is ascribed to pho

  • Change text problem CS3

    I am having problems with i2of5 barcode where some of the encoded values for the barcode are the same as InDesign values. e.g. find text "barcode" change text "ËU(K\tÌ" inDesign recognizes the \t for a tab. Is it possible to turn off these keywords o

  • Personnel number in CATS_DA with BAdI

    I would like to fill the personnel number automaticly in transaction CATS_DA. Re: Select-options in CATS_DA using BAdI gave me some hints, but it's still not working the way it should. Does anyone has some example code for the method INITIALIZATION a

  • Bapi calls

    hI hw the BAPI get called when PO is goin to create by hitting the backend. Can any one jus let me knw the process, life process which is enough. Thanks. Venkat

  • Rule file - build

    Hi, i am trying to create a rule file using i want to create a dimension . i mean base dimension . can we do that . i dont see that information in dbag hakeem