Help - Sql query

Hi All,
I have a table which has data as given below...
trans_amt
2000
4000
2000
-1000
-1000
-3000
-1000
-500
i want output like
prior_amt trans_amt post_amt
null 2000 2000
2000 4000 6000
6000 2000 8000
8000 -1000 7000
7000 -1000 6000
6000 -3000 3000
3000 -1000 2000
2000 -500 1500
how can i get the output ?
Thanks
kt

Hi,
Try
WITH TAB AS
(select     2000 VAL     from dual union all
select     4000     from dual union all
select     2000     from dual union all
select     -1000     from dual union all
select     -1000     from dual union all
select     -3000     from dual union all
select     -1000     from dual union all
select     -500     from dual
SELECT LAG(VAL,1) OVER (ORDER BY SRN)PREV_VAL, VAL,NVL(LAG(VAL,1) OVER (ORDER BY SRN),0)+ VAL SUM_VAL
FROM (SELECT VAL, ROWNUM SRN
FROM TAB) TAB;
PREV_VAL     VAL     SUM_VAL
     2000     2000
2000     4000     6000
4000     2000     6000
2000     -1000     1000
-1000     -1000     -2000
-1000     -3000     -4000
-3000     -1000     -4000
-1000     -500     -1500*009*
Edited by: 009 on Mar 15, 2010 4:12 AM
Disclaimer: wait don't use it yet!!!
Edited by: 009 on Mar 15, 2010 4:15 AM

Similar Messages

  • Help SQL Query (Not working as it should)

    Hello everybody,
    I'm using JDeveloper 12.1.2.0.0 . I'm doing a bidirectional comunication using 3 tables, with bindings between them (and using HR schema).
    In my example, i have something like:
    Departments, Employees and SalaryByJobs (i created this table where it shows the departmentd id, employee id, job, salary).
    Whenever i click on one OR more departments, the employees table update by putting on the table, the employees that belong to the selected department and the salaryByjob put the jobs by employees selected on the employees table.
    So it's something like this:
    Departments selected -> employees selected -> salarybyjbobs of those employees.
    My Employees query (in the view) has the following code:
    SELECT Employees.COMMISSION_PCT,
           Employees.DEPARTMENT_ID,
           Employees.EMAIL,
           Employees.EMPLOYEE_ID,
           Employees.FIRST_NAME,
           Employees.HIRE_DATE,
           Employees.JOB_ID,
           Employees.LAST_NAME,
           Employees.MANAGER_ID,
           Employees.PHONE_NUMBER,
           Employees.SALARY
    FROM  EMPLOYEES Employees
    WHERE ( DEPARTMENT_ID IN (select * from THE(select cast( in_list(:variavel3) as mytableType ) from dual ) a))
    Since i use bindings, the employees table don't show anything in the beginning, so i added this parte to my employees query: OR nvl(:variavel3,0) = 0
    But now, whenever i try to select more than one row, it gives me invalid numbers and i don't understand why..
    It's only more one line of code and it's not in the bean.
    Can anyone help me?
    Ps - The bean goes department by department, appends the departments with "," and for each department, gets the employees that belongs to them.
    My best regards,
    Frederico Barracha.

    The expression NVL(:variavel3,0)=0 is not correct. The datatype of the return value of the NVL function is considered equal to the datatype of the 1st argument (i.e to the datatype of the bind variable :variavel3). You said that this variable contained a comma-separated list of IDs, so the variable's datatype is VARCHAR2. As far as you are comparing the NVL-expression to a number, you get "Invalid number" exception, because Oracle is expecting a numeric datatype at the left side of the comparison operator.
    In order to avoid the "Invalid number" exception you can modify the expression using one of the following options:
    :variavel3 IS NULL
    NVL( :variavel3, '*' ) = '*'
    NVL( :variavel3, '0' ) = '0'
    The 1st option if the simplest and the most clear one.
    Dimitar

  • Nees Help: Sql Query

    [http://www.srikanthtechnologies.com/oracle/dec9/hrqueries.html] Learning sql.
    From HR Model : Find employees with the highest salary from each country.
    HR model link is attached.
    Edited by: 999344 on Apr 10, 2013 1:16 PM

    Hi,
    Welcome to the forum!
    999344 wrote:
    Learning sql.
    From HR Model : Find employees with the highest salary from each country.That;s an example of a Top-N Query . Search for "top-n query" and you;ll get lots of examples, such as {message:id=3739578}
    HR model link is attached.Really?

  • Help: SQL query when parsed returns Invalid Identifier error

    Hi The expression posted below is the actual SQL Expression which is required in my report:
    ((select name from (
    select loc_id,name,row_number()over(  order by r)  rn from (
    SELECT 0, loc_id, Misc1_txt  NAME,'A' STATUS ,rownum r
                        FROM dvxloc
                       WHERE loc_id = "XXXLOC"."LOC_ID"
                       union
    SELECT     parent_loc_id, loc_id, (SELECT a.Misc1_txt
                                                         FROM dvxloc a
                                                        WHERE a.loc_id =b.loc_id) NAME,'B' ,ROWNUM
                            FROM dvxlocpath b
                      START WITH b.loc_id = "XXXLOC"."LOC_ID"
                      CONNECT BY PRIOR  parent_loc_id=loc_id
    )                where name is NOT NULL        order by STATUS, R
    ) where rn = 1))
    It gives an error while parsing: "XXXLOC"."LOC_ID" invalid identifier
    LOC_ID is of numeric data type in the database. and when I run thi query in SQL editor after replacing "XXXLOC"."LOC_ID" with a numeric value say 456 . The query can be put as
    ((select name from (
    select loc_id,name,row_number()over(  order by r)  rn from (
    SELECT 0, loc_id, Misc1_txt  NAME,'A' STATUS ,rownum r
                        FROM dvxloc
                       WHERE loc_id = 456                   union
    SELECT     parent_loc_id, loc_id, (SELECT a.Misc1_txt
                                                         FROM dvxloc a
                                                        WHERE a.loc_id =b.loc_id) NAME,'B' ,ROWNUM
                            FROM dvxlocpath b
                      START WITH b.loc_id = 456                  CONNECT BY PRIOR  parent_loc_id=loc_id
    )                where name is NOT NULL        order by STATUS, R
    ) where rn = 1))
    The above query runs flawlessly in a SQL editor. and also this is parsed by the crystal sql expression editer
    I'm totally messed up of looking for altenatives. I have to deliver a report to the client and stuck on this part only.
    The below query parses perfectly in crystal:
    (select locname
    from dvxloc where loc_id in(select loc3 from dvxlocpath
    where loc_id = "XXXLOC"."LOC_ID"))
    Edited by: vipulbhatia29 on May 8, 2009 11:06 AM
    Edited by: vipulbhatia29 on May 8, 2009 11:14 AM

    You said the above works in SQL Editor but does your original work?
    ((select name from (
    select loc_id,name,row_number()over( order by r) rn from (
    SELECT 0, loc_id, Misc1_txt NAME,'A' STATUS ,rownum r
    FROM dvxloc
    WHERE loc_id = "XXXLOC"."LOC_ID"
    union
    SELECT parent_loc_id, loc_id, (SELECT a.Misc1_txt
    FROM dvxloc a
    WHERE a.loc_id =b.loc_id) NAME,'B' ,ROWNUM
    FROM dvxlocpath b
    START WITH b.loc_id = "XXXLOC"."LOC_ID"
    CONNECT BY PRIOR parent_loc_id=loc_id
    ) where name is NOT NULL order by STATUS, R
    ) where rn = 1))
    Crystal does nothing to the SQL in the command editor, what you type in is what we pass.
    What database are you connecting to? And if it has a tracing tool what SQL are you seeing from Crystal when you try to run the report?

  • Need help - sql query

    Hi,
         I have two tables(production & sales). I want to generate monthly statement. The followings are the sample data.
    PRODUCTION:
    DATE          MATERIAL     WEIGHT      AMOUNT
    01/12/2008     Item1     300     6000
    03/12/2008     item2          250      3500
    07/12/2008     item3          700     6500
    12/12/2008     item1          200     4000
    20/12/2008     item3          400     9600
    25/12/2008     item1          250     5000
    Sales:
    SAL_Date          Sal_Material     sal_weight     SAL_Amount
    12/12/2008     item3          270     2300
    15/12/2008     item1          200     4000
    20/12/2008     item2          250     3500
    20/12/2008     item1          100     2000
    23/12/2008     item1          100     2000
    27/12/2008     item3          200     3500
    I want to generate monthly statement like the following....
    Required Report:
    Date          Production          Sales
              Weight - Amount      Weight - Amount          
    01/12/2008     300     6000          0     0
    02/12/2008     0     0     0     0
    03/12/2008     250     3500          0     0           
    04/12/2008     0 0 0 0
    07/12/2008     700 6500 0 0
    12/12/2008     200     4000     270 2300
    31/12/2008 0 0 0 0
    i don't know, how to generate sequential date...
    Could you please tell me the query?
    Thanks & Regards

    SQL> with prod
      2  as
      3  (
      4     select to_date('01/12/2008','dd/mm/yyyy') dt, 'Item1' material, 300 weight, 6000 amount from dual union all
      5     select to_date('03/12/2008','dd/mm/yyyy'), 'item2', 250, 3500 from dual union all
      6     select to_date('07/12/2008','dd/mm/yyyy'), 'item3', 700, 6500 from dual union all
      7     select to_date('12/12/2008','dd/mm/yyyy'), 'item1', 200, 4000 from dual union all
      8     select to_date('20/12/2008','dd/mm/yyyy'), 'item3', 400, 9600 from dual union all
      9     select to_date('25/12/2008','dd/mm/yyyy'), 'item1', 250, 5000 from dual
    10  ), sales
    11  as
    12  (
    13     select to_date('12/12/2008','dd/mm/yyyy') dt, 'item3' material, 270 weight, 2300 amount from dual union all
    14     select to_date('15/12/2008','dd/mm/yyyy'), 'item1', 200, 4000 from dual union all
    15     select to_date('20/12/2008','dd/mm/yyyy'), 'item2', 250, 3500 from dual union all
    16     select to_date('20/12/2008','dd/mm/yyyy'), 'item1', 100, 2000 from dual union all
    17     select to_date('23/12/2008','dd/mm/yyyy'), 'item1', 100, 2000 from dual union all
    18     select to_date('27/12/2008','dd/mm/yyyy'), 'item3', 200, 3500 from dual
    19  ),find_date
    20  as
    21  (
    22     select dt st, last_day(dt) ed
    23       from (select distinct trunc(dt,'month') dt from prod
    24             union
    25             select distinct trunc(dt,'month') dt from sales)
    26  ),day_list
    27  as
    28  (
    29     select (level-1)+st dt
    30       from find_date
    31     connect by level <= (ed - st)+1
    32  )
    33  select d.dt, t.p_weight, t.p_amount, t.s_weight, t.s_amount
    34    from day_list d
    35    left join
    36         (select decode(p.dt,null,s.dt,p.dt) dt,
    37                    sum(p.weight) p_weight, sum(p.amount) p_amount, sum(s.weight) s_weight, sum(s.amount) s_amount
    38            from prod p
    39            full outer join sales s
    40              on p.dt = s.dt
    41             and p.material = s.material
    42           group by decode(p.dt,null,s.dt,p.dt)) t
    43      on d.dt = t.dt
    44  order by d.dt
    45  /
    DT          P_WEIGHT   P_AMOUNT   S_WEIGHT   S_AMOUNT
    01-DEC-08        300       6000
    02-DEC-08
    03-DEC-08        250       3500
    04-DEC-08
    05-DEC-08
    06-DEC-08
    07-DEC-08        700       6500
    08-DEC-08
    09-DEC-08
    10-DEC-08
    11-DEC-08
    DT          P_WEIGHT   P_AMOUNT   S_WEIGHT   S_AMOUNT
    12-DEC-08        200       4000        270       2300
    13-DEC-08
    14-DEC-08
    15-DEC-08                              200       4000
    16-DEC-08
    17-DEC-08
    18-DEC-08
    19-DEC-08
    20-DEC-08        400       9600        350       5500
    21-DEC-08
    22-DEC-08
    DT          P_WEIGHT   P_AMOUNT   S_WEIGHT   S_AMOUNT
    23-DEC-08                              100       2000
    24-DEC-08
    25-DEC-08        250       5000
    26-DEC-08
    27-DEC-08                              200       3500
    28-DEC-08
    29-DEC-08
    30-DEC-08
    31-DEC-08
    31 rows selected.

  • Please help SQL query

    why this works fine
    SELECT * FROM (
    SELECT ename,deptno,sal ,ROWNUM RN FROM emp)
    WHERE MOD(RN,3)=0
    while
    SELECT rownum FROM employees WHERE MOD(Rownum,3)=0
    wotnh works
    why this happenssssssssssssss

    ROWNUM is dynamically determined on-the-fly during the fetching of results.
    So this works:
    SELECT * FROM table WHERE rownum < 11
    It will return the first 10 rows. The following does not work:
    SELECT * FROM table WHERE rownum between 11 and 20
    As ROWNUM is added as the results are fetched from the database, it can only be used as a stopkey.
    To use ROWNUM as any other column in a predicate, you need to change ROWNUM from a "dynamic on-the-fly" column into a "proper" column. Just as you did with your 1st SELECT.
    E.g.WITH my_results AS(
            SELECT rownum AS RNO, o.* FROM all_objects o WHERE object_type = 'TRIGGER'
    SELECT
            object_id,
            object_name
    FROM    my_results
    WHERE   rno between 11 and 20

  • HELP!   SQL Query:  Other ways to reorder column display?

    I have a SQL query report with a large number of columns (users can hide/show columns as desired). It would be great if the column display order could be changed by changing the order of the columns in the SELECT list in the Report Definition, but that doesn't work -- it puts changed or added columns at the end regardless of the order in the SELECT list of the query.
    Is there some other way to reorder the columns displayed without using the Report Attributes page? It's extremely tedious to move columns around using the up/down arrows which redisplays the page each time. Am I missing a way to change display order, or does anyone have a "trick" to do this? It's so painful....
    When defining forms you can reoder columns by specifying a sequence number for each column. Just curious as to why reports were not done the same way, and are there any plans to address this in a future release?
    Karen

    Yes, reordering columns is extremely painful.
    It is supposed to be much improved in the next version.
    See
    Re: Re-ordering columns on reports
    Moving columns up/down in Report  Attributes
    See my example at
    http://htmldb.oracle.com/pls/otn/f?p=24317:141
    Basically, let the users move columns around until they are blue in the face, provide a Save button to save the column order in a user preference and reorder the columns when the page reloads.
    Or you can use Carl's PL/SQL shuttle as the widget to specify the columns shown and their order. The shuttle is at http://htmldb.oracle.com/pls/otn/f?p=11933:27
    Hope this helps.
    Message was edited by:
    Vikas

  • SQL Query Help Needed

    I'm having trouble with an SQL query. I've created a simple logon page wherein a user will enter their user name and password. The program will look in an Access database for the user name, sort it by Date/Time modified, and check to see if their password matches the most recent password. Unfortunately, the query returns no results. I'm absolutely certain that I'm doing the query correctly (I've imported it directly from my old VB6 code). Something simple is eluding me. Any help would be appreciated.
    private void LogOn() {
    //make sure that the user name/password is valid, then load the main menu
    try {
    //open the database connection
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:LawOffice2000", "", "");
    Statement select = con.createStatement();
    String strTemp = "Select * From EMPLOYEES Where INITIALS = '" + txtUserName.getText() + "' Order By DATE Desc, TIME Desc";
    ResultSet result = select.executeQuery(strTemp);
    while(result.next()) {
    if (txtPassword.getPassword().toString() == result.getString("Password")) {
    MenuMain.main();
    else {
    System.out.println("Password Bad");
    System.out.println(txtUserName.getText());
    System.out.println(result.getString("Password"));
    break; //exit loop
    //close the connection
    con.close(); }
    catch (Exception e) {
    System.out.println("LawOfficeSuite_LogOn: " + e);
    return; }
    }

    The problem is here: "txtPassword.getPassword().toString() == result.getString("Password"))"
    Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same characters), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus ==

  • URGENT HELP Required: Solution to avoid Full table scan for a PL/SQL query

    Hi Everyone,
    When I checked the EXPLAIN PLAN for the below SQL query, I saw that Full table scans is going on both the tables TABLE_A and TABLE_B
    UPDATE TABLE_A a
    SET a.current_commit_date =
    (SELECT MAX (b.loading_date)
    FROM TABLE_B b
    WHERE a.sales_order_id = b.sales_order_id
    AND a.sales_order_line_id = b.sales_order_line_id
    AND b.confirmed_qty > 0
    AND b.data_flag IS NULL
    OR b.schedule_line_delivery_date >= '23 NOV 2008')
    Though the TABLE_A is a small table having nearly 1 lakh records, the TABLE_B is a huge table, having nearly 2 and a half crore records.
    I created an Index on the TABLE_B having all its fields used in the WHERE clause. But, still the explain plan is showing FULL TABLE SCAN only.
    When I run the query, it is taking long long time to execute (more than 1 day) and each time I have to kill the session.
    Please please help me in optimizing this.
    Thanks,
    Sudhindra

    Check the instruction again, you're leaving out information we need in order to help you, like optimizer information.
    - Post your exact database version, that is: the result of select * from v$version;
    - Don't use TOAD's execution plan, but use
    SQL> explain plan for <your_query>;
    SQL> select * from table(dbms_xplan.display);(You can execute that in TOAD as well).
    Don't forget you need to use the {noformat}{noformat} tag in order to post formatted code/output/execution plans etc.
    It's also explained in the instruction.
    When was the last time statistics were gathered for table_a and table_b?
    You can find out by issuing the following query:select table_name
    , last_analyzed
    , num_rows
    from user_tables
    where table_name in ('TABLE_A', 'TABLE_B');
    Can you also post the results of these counts;select count(*)
    from table_b
    where confirmed_qty > 0;
    select count(*)
    from table_b
    where data_flag is null;
    select count(*)
    from table_b
    where schedule_line_delivery_date >= /* assuming you're using a date, and not a string*/ to_date('23 NOV 2008', 'dd mon yyyy');

  • Need Help in Splitting a String Using SQL QUERY

    Hi,
    I need help in splitting a string using a SQL Query:
    String IS:
    AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
    Sample Output should look like:
    SNO       STRING
    1            AFTER PAINT
    2            ACOUSTICAL
    3            1
    4            
    5            9" MEMBRAIN
    {code}
    FYI i am using Oracle 9.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There's this as well:
    with x as ( --generating sample data:
               select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
               select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
    select str,
           row_number() over (partition by str order by rownum) s_no,
           cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
    from x,
         table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
    STR                                                S_NO RES                                                                                                
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 1 AFTER PAINT                                                                                        
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 2 ACOUSTICAL                                                                                         
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 3 1                                                                                                  
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 4                                                                                                    
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 5 9" MEMBRAIN                                                                                        
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          1 BEFORE PAINT                                                                                       
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          2 ELECTRIC                                                                                           
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          3 2                                                                                                  
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          4                                                                                                    
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          5 45 caliber MEMBRAIN      
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • XML Generation using a sql query in an efficient way -Help needed urgently

    Hi
    I am facing the following issue while generating xml using an sql query. I get the below given table using a query.
         CODE      ID      MARK
    ==================================
    1 4 2331 809
    2 4 1772 802
    3 4 2331 845
    4 5 2331 804
    5 5 2331 800
    6 5 2210 801
    I need to generate the below given xml using a query
    <data>
    <CODE>4</CODE>
    <IDS>
    <ID>2331</ID>
    <ID>1772</ID>
    </IDS>
    <MARKS>
    <MARK>809</MARK>
    <MARK>802</MARK>
    <MARK>845</MARK>
    </MARKS>
    </data>
    <data>
    <CODE>5</CODE>
    <IDS>
    <ID>2331</ID>
    <ID>2210</ID>
    </IDS>
    <MARKS>
    <MARK>804</MARK>
    <MARK>800</MARK>
    <MARK>801</MARK>
    </MARKS>
    </data>
    Can anyone help me with some idea to generate the above given CLOB message

    not sure if this is the right way to do it but
    /* Formatted on 10/12/2011 12:52:28 PM (QP5 v5.149.1003.31008) */
    WITH data AS (SELECT 4 code, 2331 id, 809 mark FROM DUAL
                  UNION
                  SELECT 4, 1772, 802 FROM DUAL
                  UNION
                  SELECT 4, 2331, 845 FROM DUAL
                  UNION
                  SELECT 5, 2331, 804 FROM DUAL
                  UNION
                  SELECT 5, 2331, 800 FROM DUAL
                  UNION
                  SELECT 5, 2210, 801 FROM DUAL)
    SELECT TO_CLOB (
                 '<DATA>'
              || listagg (xml, '</DATA><DATA>') WITHIN GROUP (ORDER BY xml)
              || '</DATA>')
              xml
      FROM (  SELECT    '<CODE>'
                     || code
                     || '</CODE><IDS><ID>'
                     || LISTAGG (id, '</ID><ID>') WITHIN GROUP (ORDER BY id)
                     || '</ID><IDS><MARKS><MARK>'
                     || LISTAGG (mark, '</MARK><MARK>') WITHIN GROUP (ORDER BY id)
                     || '</MARK></MARKS>'
                        xml
                FROM data
            GROUP BY code)

  • Help Required -- Can we use SQL Query to READ data from SAP MDM Tables

    Hi All,
    Please help.........
    Can we use SQL Query to READ(No Creation/Updation/Deletion  just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
    Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
    Thanks in Advance
    Regards

    All the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
    Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
    But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
    BR,
    Alok

  • Need help in Report From SQL Query

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    user602513 wrote:
    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?Do you get any errors or warnings or it is just the slow speed which is the issue?
    There could be a variety of reasons for the delayed processing of this report. That includes parameter settings for that page, cache settings, network configurations, etc.
    - explore best optimization for your query;
    - evaluate portal for best performance configuration; you may follow this note (Doc ID: *438794.1* ) for ideas;
    - third: for that particular page carrying that report, you can use caching wisely. browser cache is neither decent for large files, nor practical. instead, explore the page cache settings that portal provides.
    - also look for various log files (application.log and apache logs) if you are getting any warnings reflecting on some kind of processing halt.
    - and last but not the least: if you happen to bring up a portal report with more than 10000 rows for display then think about the usage of the report. Evaluate whether that report is good/useful for anything?
    HTH
    AMN

  • Need Help in SQL Query

    Hi all,
    I have data in the following manner:
    CASE_NUMBER HOURS FLAG
    1000 10 0
    1000 20 0
    1000 30 1
    1000 40 0
    1000 50 1
    Here I need to Calculate the total hours for a Case_number till i see the flag as 1.
    Here the result must be 10+20+30 Hrs
    Another Example
    CASE_NUMBER HOURS FLAG
    2000 10 1
    2000 20 1
    Here the result must be only 10.
    I am struggling to write a SQL query for this.
    Anyones help will be very much greatful
    Thanks in Advance
    Regards,
    Sengathir Subbarayan

    Look up analytical functions.
    something like sum(hours) OVER (PARTITION BY case_number ORDER BY something)
    will give you the sum for all rows.
    Then you probably want to "throw away" those rows after the flag maybe by summing the flag column too, and throw away all those where the flag is greater than 1 and where it is equal to 1 except for the first one.
    I suspect you actually have some other column (other than the number of hours) that define your order - that's what you put in the ORDER BY.
    Jon

  • Help needed in executing SQL query...

    Hi,
    I am very new to JDeveloper. Curently i am tryin to execute an SQL query from the BPEL process, the output of the query is to be mapped to a variable field from a target xsd file. the query is fairly simple, like
    SELECT emp
    FROM emp_table
    WHERE emp_id=123
    The target field, namely "employee", is an element from the xsd file. I tried using Java embedding activity to connect to the db and execute the query through a piece of Java code, but couldn't find a way to assign the output of the query to the field. however lately i also discovered the Database Adapter services which helps me create a database connection, but still i am not sure as of how to handle and map the output of the query to the variable field.
    Can somebody please help me in resolving the issue either through Java Embed activity or Database Adapter services??
    Thanks in advance
    Anjan

    Anjan,
    I suggest you try the [url http://forums.oracle.com/forums/forum.jspa?forumID=212]BPEL Forum
    John

Maybe you are looking for

  • Old computer game i can't remember the name of

    I remember playing a mac computer game when i was younger but i can't remember what it was called. All i remember is that the main character had a big chin and had to fight through candy worlds. I'm pretty sure that he carried a big gun but I might b

  • Lightroom 5 (trial) will not open

    I am a Lightroom 3 user who is trying to migrate to a new Win8 computer. I initially tried to get LR3.6 on my new machine but had problems. As LR3 is not supported I've decided to upgrade. I downloaded LR5 onto my new machine using Firefox, went thro

  • Upgrade from M58p to M90p - without reinstalli​ng Windows? sysprep?

    Hi, I have a M58p which currently has Windows 8.1 installed. I have the opportunity to upgrade to a M90p but I dont wish to go through the hassle of re-installing Windows and Office plus other applications. I have read on a few sites that I may be ab

  • Getting error when installing 12.1.1 "Insufficient privileges C:\iTunes\iTunes.Resources\nl.lproj"

    Running Windows 8.1 and I'm the only account on my pc so I have admin rights. I did install the last update successfully so not sure why this one doesn't want to install.

  • Motion generators won't open in fcx

    after the recent updates to fcx and motion 5......generators created in motion will not open in Final Cut. Old ones created before update still work find when placed on timeline. When placing the new generators on the timeline the error visual simial