Need query to find out the sum till a period

Hi,
I need to write one query to find out the cumulative sum of raw_cost of table pa_budget_lines till the specified period, I tried to do this by analytical function, but that is not working in Report 10g. Can anybody help me in this.
Thanks

not familiar with report but could you do something like this
with t as
  select 1 grp, 10 * level the_cost, add_months (sysdate,  level) effective_dt from dual connect by  level < 11 union all
  select 2 grp, 5 * level the_cost, add_months (sysdate,  level) effective_dt from dual connect by  level < 11
input as
  ( select null grp, null the_cost, null running_total,  v_eff_dt effective_dt   from dual)
select * from(
select t.grp, t.the_cost, sum(t.the_cost) over (partition by t.grp order by t.effective_dt) running_total, t.effective_dt,
       lead(t.effective_dt) over (partition by t.grp order by t.effective_dt) next_effective_dt,
       input.effective_dt  inp_eff_dt
from t, input
where inp_eff_dt between effective_dt and next_effective_dtv_eff_dt would be the input date you are interested in

Similar Messages

  • Query to find out the time used by an user for an application

    Hello All,
    I want to know the query to find out the whole time used by the user for an application. Please view the below data
    Employee:
    SNO EMP_ID EMP_NAME EMP_DATE LOGIN_TIME LOGOUT_TIME
    1 10 Visu 21-Nov-2010 06:30:00 07:30:00
    2 10 Visu 21-Nov-2010 06:40:00 07:20:00
    3 10 Visu 21-Nov-2010 06:50:00 07:50:00
    4 10 Visu 21-Nov-2010 07:30:00 08:30:00
    5 10 Visu 21-Nov-2010 09:30:00 10:30:00
    By checking the above data we can say that the total time Visu used the application is
    8.30 - 6.30 (From 1,2,3,4 records) = 2hrs
    10.30 - 9.30 (Based on 5th rec) = 1hr
    So the total time Visu used the application would be 3 hrs = 180 mins.
    Could you please help me in getting the result from that data using a query?

    odie_63 wrote:
    I think it may be solved with analytics too.
    with t1 as (
                select 1 sno,10 emp_id,'Visu' emp_name,'21-Nov-2010' emp_date,'06:30:00' login_time,'07:30:00' logout_time from dual union all
                select 2,10,'Visu','21-Nov-2010','06:40:00','07:20:00' from dual union all
                select 3,10,'Visu','21-Nov-2010','06:50:00','07:50:00' from dual union all
                select 4,10,'Visu','21-Nov-2010','07:30:00','08:30:00' from dual union all
                select 5,10,'Visu','21-Nov-2010','09:30:00','10:30:00' from dual
         t2 as (
                select  emp_id,
                        emp_name,
                        emp_date,
                        to_date(emp_date || login_time,'DD-MON-YYYYHH24:MI:SS') login_time,
                        to_date(emp_date || logout_time,'DD-MON-YYYYHH24:MI:SS') logout_time
                  from  t1
         t3 as (
                select  t2.*,
                        case
                          when login_time < max(logout_time) over(
                                                                  partition by emp_id,emp_date
                                                                  order by login_time
                                                                  rows between unbounded preceding
                                                                           and 1 preceding
                            then 0
                          else 1
                        end start_of_group
                  from  t2
         t4 as (
                select  t3.*,
                        sum(start_of_group) over(partition by emp_id,emp_date order by login_time) grp
                  from  t3
         t5 as (
                select  emp_id,
                        emp_date,
                        min(login_time) login_time,
                        max(logout_time) logout_time
                  from  t4
                  group by emp_id,
                           emp_date,
                           grp
    select  emp_id,
            numtodsinterval(sum(logout_time - login_time),'day') time_spent
      from  t5
      group by emp_id
      order by emp_id
        EMP_ID TIME_SPENT
            10 +000000000 03:00:00.000000000
    SQL> SY.

  • Query to find out the list of user who have delete access

    Hi,
    I need a query to find out the list of users who have delete access on perticular folder/universe/ reports  in infoview.
    Please advice.
    Regards,
    Neo.

    orton607 wrote:
    thanks for replying guys. But the thing is i am using dynamic sql execute immediate in my package, so i want those tables also and the schema name.
    thanks,
    ortonThis is not possible. The best you could do is to have a good guess.
    Or how would you parse some dynamic statement as this:
       v_suffix := 'loyees';
       v_sql := 'Select count(*) from (select ''nonsense'' col1 from emp'||v_suffix||') where col1 = ''Y'''';
       execute_immediate(v_sql);
    ...What is the table name? How do you want to parse that?
    Better rewrite all dynamic SQL statements into non dynamic ones. Or do the source control logic for those dynamic parts in an extra module. For example implement your own dependency table and force every developer to add there all dynamic parts.

  • Query to find out the Activities done against a table

    Hi,
    One table has been truncated and data reloaded into the table by the user. But at latter stage user deny that activity. I believe all these activities stored in any oracle 10g database table.
    Need a query to find out the activities done on a specific date say 6th Sep.
    This is too urgent. Thanks in advance

    Hi,
    Welcome to the forum!
    If you don't have enable table auditing maybe you can see last_ddl_time column of user_objects view:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> select * from test2;
          COL1       COL2       COL3
             1          1          3
             1          2          3
             1          3          3
    SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
    TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
    12/09/2009 12:20:26            12/09/2009 12:20:27
    SQL> truncate table test2;
    Table truncated
    SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
    TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
    12/09/2009 12:20:26            12/09/2009 14:01:21
    SQL> Regards,

  • Query to find out the free disk space on C: drive

    Hi Guys,
    I am trying to create a query in  Queries section under Monitoring, To find out the free disk space of C: drive.
    Am using the below query, but it shows lot many fields, I need only Machine names of the collection and their
    Free Disk Space on C: drive
    select * from SMS_R_System inner join SMS_G_System_LOGICAL_DISK on SMS_G_System_LOGICAL_DISK.ResourceId = SMS_R_System.ResourceId where SMS_G_System_LOGICAL_DISK.DeviceID = "C:" and SMS_G_System_LOGICAL_DISK.FreeSpace > 1024
    Please assist

    The SELECT part of the query will govern what fields you are shown, so perhaps try:
    Select SMS_R_System.ResourceID, SMS_R_System.NETBIOSname, SMS_G_System_Logical_Disk.FreeSpace
    from SMS_R_System
    inner join SMS_G_System_LOGICAL_DISK on SMS_G_System_LOGICAL_DISK.ResourceId = SMS_R_System.ResourceId
    where SMS_G_System_LOGICAL_DISK.DeviceID = "C:" and SMS_G_System_LOGICAL_DISK.FreeSpace > 1024
    I hope that helps,
    Nash
    Nash Pherson, Senior Systems Consultant
    Now Micro -
    My Blog Posts
    If you found a bug or want the product to work differently,
    share your feedback.
    <-- If this post was helpful, please click the up arrow or propose as answer.

  • Query to find out the list of tables used in a package

    hello,
    can anyone please help me out with a query; i want to find out the list of tables used by a particular package.
    thanks,
    orton

    orton607 wrote:
    thanks for replying guys. But the thing is i am using dynamic sql execute immediate in my package, so i want those tables also and the schema name.
    thanks,
    ortonThis is not possible. The best you could do is to have a good guess.
    Or how would you parse some dynamic statement as this:
       v_suffix := 'loyees';
       v_sql := 'Select count(*) from (select ''nonsense'' col1 from emp'||v_suffix||') where col1 = ''Y'''';
       execute_immediate(v_sql);
    ...What is the table name? How do you want to parse that?
    Better rewrite all dynamic SQL statements into non dynamic ones. Or do the source control logic for those dynamic parts in an extra module. For example implement your own dependency table and force every developer to add there all dynamic parts.

  • Please let me know a good query to find out the memory being used in DB

    Hi All,
    We are using Automotic memory management by using parameter memory_target option. I want to find out the total memory being used and which is free.
    ie;(SGA+PGA). Please let me know.
    Thanks & Regards,
    Vikas Krishna

    Since we are using memry_target we will not get an accurate value there I guess.
    SQL> show parameter memory
    NAME TYPE VALUE
    hi_shared_memory_address integer 0
    memory_max_target big integer 12G
    memory_target big integer 12G
    shared_memory_address integer 0
    SQL> select round(used.bytes /1024/1024 ,2) used_mb
    2 , round(free.bytes /1024/1024 ,2) free_mb
    3 , round(tot.bytes /1024/1024 ,2) total_mb
    4 from (select sum(bytes) bytes
    5 from v$sgastat
    6 where name != 'free memory') used
    7 , (select sum(bytes) bytes
    8 from v$sgastat
    9 where name = 'free memory') free
    10 , (select sum(bytes) bytes
    11 from v$sgastat) tot;
    USED_MB FREE_MB TOTAL_MB
    1660.92 378.71 2039.62
    Thanks & Regards,
    Vikas Krishna

  • Query to find out the table name and column name..

    Hi Experts,
    I have an Oracle DB in which has more than 50 tables and 100,000 records. I want to get the record which contains *"ITxtVarValue references a non existing text"* the text.
    Is there any query there to find out the table name and column name of this particular record where it reside?
    Please help. Any help will be rewarded.
    Thanks,
    G

    Using this forum's search function, I found a thread that should give you an idea: How to find out a tablename
    C.

  • Sql query to find out the space issues in not able to allocate next extent

    hi,
    i have oracel 11g on linux.
    my datafiles are autoextend off. i am looking for query to make sure the segments does not stop growing by reaching the maximum segment allocated or no free contigous space available in allocating new extent,.
    i need to know periodically the owner,object_name and object type (table or index) which are suffocating for space.
    any ad-hoc sql query exists?
    thanks in advance.

    Connect as sysdba and try..
    To list all objects >100M in size.
    SQL> select owner, segment_type, segment_name, sum(bytes)/(1024*1021) from dba_segments
    group by owner, segment_type, segment_name
    having sum(bytes)/(1024*1021) > 100
    For tablespaces ..
    select tablespace_name, sum(bytes) tablespace_size
    from dba_data_files
    group by tablespace_name
    union all
    select tablespace_name, sum(bytes) tablespace_size
    from dba_temp_files
    group by tablespace_name
    order by tablespace_name

  • Query to find out the sales order

    Hi All,
    I need a query to find sales order number against which a serial number is transacted.
    Can ny one help onthis.
    Thanks ,

    hi,
    thanks you for your reply.
    its working but i am not able to see the required item serail number.
    Bit confused its their in mtl_serial_number but its not their in sales order.
    How is it possible.
    In mtl_serial_number its current_status is '4'
    Can you please hlep me.
    Thanks

  • Need query to find out whether exactly 2 columns are used in any index ?

    Suppose i have two columns ID and Status (or any number of columns ) belongs to table customer...
    Now I want to create below index
    Ex. create index test1 on customer (ID , Status )
    But before creating this index i want to check that whether there is already index on these 2 columns ? May be by other name ?
    Need query for this.
    Plz help.

    Hi Shubhangi,
    Your requirement is very difficult to fulfill , i have made an attempt to replicate your reqrmnt & write a query wherein you need to compromise on few things , let us see if it works for you
    Supply table_name/owner & Number of column on which you want to find indexes
    e.g.
    select distinct INDEX_NAME,column_name
    from dba_ind_columns
    where index_name in (select distinct index_name
    from dba_ind_columns
    where table_name='&table_name'
    and table_owner='&owner'
    having count(column_name)=&column_count group by index_name);
    Enter value for table_name: ADDRESS
    Enter value for owner: ASAP
    Enter value for column_count: 2
    INDEX_NAME COLUMN_NAME
    FKIDX_AD__SF_ST_FO SF_STRUC_FORMAT_NM
    FKIDX_AD__SF_ST_FO SF_TYPE_NM
    SQL> /
    Enter value for table_name: ADDRESS
    Enter value for owner: ASAP
    Enter value for column_count: 3
    INDEX_NAME COLUMN_NAME
    FKIDX_AD__SF_ST_FO_1 POSTAL_CD
    FKIDX_AD__SF_ST_FO_1 SF_STRUC_FORMAT_NM
    FKIDX_AD__SF_ST_FO_1 SF_TYPE_NM
    Thanks,
    Ajay More
    http://moreajays.blogspot.com

  • Plsql query to find out the concurrent programs attaching a plsql package

    I want to find all the concurrent programs attaching a particular package. Please provide me with the appropriate query to get that.

    Hello,
    1- First thing: we are talking about a SQL query (and not a PL/SQL query).
    2- I would like to add an additional filter to the query of shazi as the query should show only PL/SQL packages
    SELECT
    fcp.CONCURRENT_PROGRAM_ID
    ,fcp.concurrent_program_name
    , fcpt.user_concurrent_program_name
    , DECODE(fe.execution_method_code
    , 'I', 'PL/SQL'
    ,'P', 'Reports'
    ,'C', 'SQL Loader'
    ,'Q', 'SQL Plus'
    ,'K', 'Java'
    ,'H', 'OS executable'
    ,'B' , 'Req. Set Stage'
    ) EXECUTION_METHOD
    ,UPPER(EXECUTION_FILE_NAME) PACKAGE_BODY
    from
    fnd_concurrent_programs_tl fcpt
    , fnd_executables fe
    ,fnd_concurrent_programs fcp
    where 1=1
    --and fcpt.concurrent_program_id = fcr.concurrent_program_id
    and fe.executable_id = fcp.executable_id
    and fcpt.concurrent_program_id = fcp.concurrent_program_id
    and fe.execution_method_code = 'I' /* here's the additional filter */
    --and fcpt.user_concurrent_program_name = :P_USER_CONC_PROGRAM_NAME
    --fcp.concurrent_program_name = :P_CONC_PROGRAM_NAME /* using this filter would use an index */
    Lalaina

  • Need help to find out the navigational attribute where used list ?

    HI all ,
    i have a 0BATCH_0PLANT  navigational attribute ,  i want to find out  , where it has been used in the all the queries  .
    Thanks ,

    Nav-attribute will also be see as a attribute in the system search for it and click on where used list of it.
    Search for the Info object 0BATCH_0PLANT. double click on it -- click on the where used list of the nav-attribute.
    It will display all the dependent objects where its used.
    With this you can get the IC,DSO,MP names where this object is used. next with the help of those MP,IC and DSO you can get the list of queries.

  • Need query to find out object Accessibility

    Hi Gurus,
    I am in need of a query that can show object accessibiliy .i.e
    given table can be accessed by which all oracle users.
    it should take into account grants given by roles.
    Please help.
    Regrads

    user5228856 wrote:
    the solution you give me l give me a all out report ,
    what i need is
    select <<>>
    from <<>>
    where object_name = owner.object_name
    result set should return what all db user has select priv on the given object.site below contains desired code
    http://www.petefinnigan.com/tools.htm

  • Query to find out the sessions trying to create table.

    Hi Folks,
    I wanted to know the sessions that are trying to create tables. I'm trying to use the query... but not getting the correct results...
    These are the three versions of queries i wrote..
    SELECT A.SID,A.USERNAME,A.SQL_ID,B.SQL_TEXT FROM V$SESSION A,V$SQLTEXT B
    WHERE A.STATUS='ACTIVE'
    AND A.SQL_ID=B.SQL_ID
    AND B.SQL_TEXT LIKE '%INSERT%' OR B.SQL_TEXT LIKE '%insert%'
    SELECT A.SID,A.USERNAME,A.SQL_ID,B.SQL_TEXT FROM V$SESSION A,V$SQLTEXT B
    WHERE A.SID IN (SELECT SID FROM V$SESSION WHERE STATUS='ACTIVE')
    AND A.SQL_ID=B.SQL_ID
    AND B.SQL_TEXT LIKE '%INSERT%' OR B.SQL_TEXT LIKE '%insert%'
    select sid, serial#, status, username, osuser,machine,sql_id from v$session
    where sql_id in (select sql_id from v$sqltext where SQL_TEXT like '%INSERT%'
    union
    select sql_id from v$sqltext where SQL_TEXT like '%insert%')
    But its not giving me the correct results. Can any one help me with a query to determine a way to catch the sessions trying to create tables.
    Thanks
    Karthik

    I'm not sure why this needs further explanation. A database is a conceptual and logical whole, it is not a dumpground. Databases are designed prior to their creation, after their creation only the content of the database change, not the database itself.
    Having end-users creating tables on the fly means you have no control over the database and also no control over it's integrity and consistency.
    Basically this means your database has been converted into a garbage dump.
    End-users creating tables on the fly is a big nono in my book, and whoever develops an application creating tables on the fly should be shown to the door of unemployment.
    You would either set up audit and issue audit table as explained before, or revoke the create table privilege from all end-users. Personally I prefer the last approach, and I wouldn't even consider the former.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for