Discoverer Date Range Union Query

Hi All,
I need your help in creating a discovere report in version 11G.
Following Report find missing elimination account based on Transaction done in a date Range. Find out how many accounts are not defined in Elimination Account Setup. Following query gives me desired output but i am having hard time creating a discoverer report for Date Range Parameter as Date Range only applied to one side of union.
In First Query i used decode with sysdate itself so that i can use effective_date as parameter and second side i just kept sysdate.
PLease let me know how can i create a parameterized report for effective_date range.
SELECT
    /*+ ORDERED
    USE_NL(jel jeh jeb cat src)
    INDEX(jel GL_JE_LINES_N1)
    INDEX(jeh GL_JE_HEADERS_U1)
    INDEX(jeb GL_JE_BATCHES_U1)
    INDEX(cat GL_JE_CATEGORIES_TL_U1)
    INDEX(src GL_JE_SOURCES_TL_U1) */
    CC.SEGMENT1
    ||'.'
    ||CC.segment2
    ||'.'
    ||CC.segment3
    ||'.'
    ||cc.segment4
    ||'.'
    || cc.segment5
    ||'.'
    || cc.segment6 Account,
    decode(sysdate,sysdate,sysdate,jel.effective_date) trx_date
  FROM gl_code_combinations cc,
    gl_je_lines jel,
    gl_je_headers jeh,
    gl_je_batches jeb,
    gl_je_categories cat,
    gl_je_sources src
  WHERE cc.CHART_OF_ACCOUNTS_ID = 50308
  AND cc.segment2              IN ('111710','201910')
  AND jel.code_combination_id   = cc.code_combination_id
  AND jel.status
    || ''                = 'P'
  AND (jel.accounted_cr != 0
  OR jel.accounted_dr   != 0)
  AND jeh.je_header_id   = jel.je_header_id
  AND jeh.actual_flag    = 'A'
  AND jeh.currency_code       != 'STAT'
  AND jeb.je_batch_id          = jeh.je_batch_id
  AND jeb.average_journal_flag = 'N'
  AND src.je_source_name       = jeh.je_source
  AND cat.je_category_name     = jeh.je_category
  and jel.effective_date between to_date('01-JAN-2011','DD-MON-RRRR') and to_date('31-MAY-2011','DD-MON-RRRR')
  MINUS
  SELECT (source_segment1
    ||'.'
    ||source_segment2
    ||'.'
    ||source_segment3
    ||'.'
    ||source_segment4
    ||'.'
    ||source_segment5
    ||'.'
    ||source_segment6) def_acnt,
    sysdate
  FROM GL_ELIM_ACCOUNTS_MAP

Hi,
You can use the following SQL to get the effective date into the SQL and by that create the condition in the report:
SELECT
CC.SEGMENT1
||'.'
||CC.segment2
||'.'
||CC.segment3
||'.'
||cc.segment4
||'.'
|| cc.segment5
||'.'
|| cc.segment6 Account,
decode(sysdate,sysdate,sysdate,jel.effective_date) trx_date,
jel.effective_date
FROM gl_code_combinations cc,
gl_je_lines jel,
gl_je_headers jeh,
gl_je_batches jeb,
gl_je_categories cat,
gl_je_sources src
WHERE cc.CHART_OF_ACCOUNTS_ID = 50308
AND cc.segment2 IN ('111710','201910')
AND jel.code_combination_id = cc.code_combination_id
AND jel.status
|| '' = 'P'
AND (jel.accounted_cr != 0
OR jel.accounted_dr != 0)
AND jeh.je_header_id = jel.je_header_id
AND jeh.actual_flag = 'A'
AND jeh.currency_code != 'STAT'
AND jeb.je_batch_id = jeh.je_batch_id
AND jeb.average_journal_flag = 'N'
AND src.je_source_name = jeh.je_source
AND cat.je_category_name = jeh.je_category
AND NOT EXISTS (
SELECT 1
FROM GL_ELIM_ACCOUNTS_MAP
WHERE CC.SEGMENT1 = source_segment1
AND CC.segment2 = source_segment2
AND CC.segment3 = source_segment3
AND cc.segment4 = source_segment4
AND cc.segment5 = source_segment5
AND cc.segment6 = source_segment6
AND decode(sysdate,sysdate,sysdate,jel.effective_date) = SYSDATE
*** I removed the hints, but if you need those get them back
*** BTW i didn't understand the logic behind the "decode(sysdate,sysdate,sysdate,jel.effective_date)" wouldn't it always be SYSDATE???
Tamir

Similar Messages

  • Date range union

    Hi!
    I have a subscription system, where people can subscribe to a publication during a certain period of time. I would like to know how long a person has subscribed to any publication, so i wonder does anyone know how to perform a "date range union"? By that, i mean that a query on this data:
    with test_data as (select 1 id, to_date('01-JAN-2000','DD-MON-YYYY') start_date, to_date('27-JUN-2003','DD-MON-YYYY') stop_date from dual union
    select 2, to_date('05-APR-2003','DD-MON-YYYY'), to_date('04-JAN-2004','DD-MON-YYYY') from dual union
    select 3, to_date('03-JUL-2002','DD-MON-YYYY'), to_date('02-JUL-2008','DD-MON-YYYY') from dual)
    select * from test_data;
    should produce
    START_DATE STOP_DATE
    01-JAN-2000 00:00:00 02-JUL-2008 00:00:00
    So there can be any number of periods, and they can overlap entirely as well as "on one end".
    I have solved this using PL/SQL, but would like to know if there is a SQL solution. I have also solved this with a fixed number of periods (2,3...) but not with any number.

    Sorry my fault. Soon after posting I found a case when the result was wrong, so I corrected the query (added default value 1 to lag(gap,1) i.e. lag(gap,1,1)) without leaving a notice. I'm home now - no database access - but I can comment to make it easier for you.
    select the_start start_date,stop_date 
      from (
    -- propagating the_start value: we keep data ordered by start date
    --                              we carry the value of the_start from overlap row to the non-overlap row
            select start_date,stop_date,gap,              
                   case when gap = 1 and lag(gap,1) over (order by start_date) = 0
                     then lag(the_start,1) over (order by start_date)
                     else start_date
                   end the_start
              from (
    -- excluding intermediate overlaps: gap = 0 and the_start is null
                    select start_date,stop_date,gap,the_start                 
                      from (
    -- identifying start days: we keep data ordered by start date
    --                         when we have the first overlap (current gap = 0, but the gap on the previous row <> 0) we record the start_date as the_start
                            select start_date,stop_date,gap,
                                   case when gap = 0 and lag(gap,1,1) over (order by start_date) = 1
                                        then start_date
                                   end the_start
                              from (
    -- identifying period breaks: we keep data ordered by start date
    --                            when the start_date on the next row is not greater than the stop_date on the current row we have an overlap
                                    select start_date,stop_date,
                                           case when lead(start_date,1) over (order by start_date) <= stop_date
                                                then 0
                                                else 1
                                           end gap
                                      from test_data
                     where gap = 1 or the_start is not null
    where gap = 1
    order by start_dateTo check intermediate results run step by step starting from the inner query (just comment out the outer queries). I'm pretty sure LAG, not LEAD
    Regards
    Etbin

  • Error when selecting date range in query designer

    hi all,
    when iam trying to select date range in query designer like 01.04.2009 to 10.04.2009 it has to select only that dates where as it is selecting all the dates in between those like 010.04.2009,01.03.2009,01.02.2009.why this is happening ,iam unable to understand.plzz help me in this issue.
    Vamshi D Krishna

    hi ,
    i have created a variable as you told but no use.still i have to select the dates manuallyone after the other.for more user friendly can i have a calander where i can select date ranges.is it posible to have calander for selecting date ranges instead selecting dates one by one,if posible i request you to give  the detailed steps.plzz guide me in this issue.thanks in advance.
    Vamshi D Krishna

  • Visual Composer: Date Range in Query

    Hi,
    While working in Visual Composer, I have come across the need to re-use the same query 20 times, but with slightly different date ranges. One way would be to create 20 copies of the same query and change the selection dates as needed on each of them. However, is it possible to provide date ranges in a query in Visual Composer? Right now its only letting me enter single values.
    Thanks
    Adeel

    Problem can be resolved by using a colon between the dates. Furthermore, the DSTR function in the expression editor can be used to form the desired dates.

  • Date Range in Query

    Hi All,
    We have created a query report which we have created as a stored procedure and we are executing the sp in SBO to get the result. However, there is one issue, we have passed the variables in the sp as well as the fms to get the date range, but if we input the date manually, the result shown is incorrect!!
    It works fine when we tab on the from date, scroll down and select the date from the cfl!! This is not acceptable to the client. They want to enter the dates manually and not select from the cfl.
    Please advise what is wrong here and how to correct this issue?? Is there any limitation of this sort..
    Thanks,
    Joseph

    Hi Joseph,
    Instead of getting the date as string, try by changing the below declaration part
    Declare @datefrom VARCHAR(20)
    DECLARE @dateto VARCHAR(20)
    by this
    Declare @datefrom datetime
    DECLARE @dateto datetime
    I think, then you need to chenge the same in the SP too
    Regards,
    Bala

  • Date range in query keydate

    Hi,
    Is the keydate in query accepts the date range, from the query properties keydate accepts one date.  I also tried from variable customer exit  it is giving an error shown below.
    EError for variable  in customer enhancement <variable name>                      
    EVariables contain invalid values.                                       
    I>> Row: 82 Inc: LRRMSU13 Prog: SAPLRRMS                                 
    ASystem error in program CL_RSR_OLAP_VAR and form INIT-02- (see long text)
    The requirement is to display multiple records from master data (the time dependent master data in the given data range) based on the keydate range provided. 
    Please respond how to resolve this.
    Thanks
    Sreedh.

    Hi Shalabh,
    Here is the output i'm looking for
    Time dependent Master data 
    Emp1           date  from         date to               Attr1          Attr2
    ABCD           01/01/2008        02/29/2008        Name1       Name2
    ABCD           03/01/2008        05/31/2008        Name3       Name4
    In query when the key date is >= 01/01/2008, the trsn data will show as
    Emp1   Attr1     Attr2       Keyfig
    ABCD  Name1  Name2    
    ABCD  Name3  Name4    30
    The keydate for the query is not accepting the range, is there anyway to achieve this.   Don't want to use the Infoset. 
    Thanks
    Sreedh

  • Date range related query needed

    I have table 'ratemast' with following columns and data
    begindate      enddate           rate1
    01-12-2006      10-12-2006     750.00
    11-12-2006      25-12-2006     950.00
    26-12-2006      02-03-2007     1500.00
    the data in begindate and enddate may fall between any date range.
    it may be for a week or for a month or even more than that.
    i need a query to do the following:
    my query will have begindate and enddate for any date range which is not defined in a single row of ratemast.
    I need to pick indiviudal date and its respective rate and sum them and it should be divided by number of days.
    eg:- if begindate: 09-12-2006 enddate: 13-12-2006
    result should be : (750+750+950+950+950)/5
    Please help.

    Hi,
    Here's one way... you may have to alter it to check for count(*) = 0 or any other corner cases.
    [email protected](152)> create table ratemast(begindate date, enddate date, rate number);
    Table created.
    Elapsed: 00:00:00.22
    [email protected](152)> insert into ratemast(begindate, enddate, rate)
    values (date '2006-12-01', date '2006-12-10', 750);
    1 row created.
    Elapsed: 00:00:00.01
    [email protected](152)> insert into ratemast(begindate, enddate, rate)
    values (date '2006-12-11', date '2006-12-25', 950);
    1 row created.
    Elapsed: 00:00:00.00
    [email protected](152)> insert into ratemast(begindate, enddate, rate)
    values (date '2006-12-26', date '2007-03-02', 1500);
    1 row created.
    Elapsed: 00:00:00.00
    [email protected](152)> commit;
    Commit complete.
    Elapsed: 00:00:00.04
    [email protected](152)> select * from ratemast
      2  /
    BEGINDATE ENDDATE         RATE
    01-DEC-06 10-DEC-06        750
    11-DEC-06 25-DEC-06        950
    26-DEC-06 02-MAR-07       1500
    Elapsed: 00:00:00.03
    [email protected](152)> var begin_date varchar2(10);
    [email protected](152)> var end_date varchar2(10);
    [email protected](152)> exec :begin_date := '2006-12-09';
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    [email protected](152)> exec :end_date := '2006-12-13';
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    [email protected](152)> @ed
    Wrote file TEST.BRANDT_152_20070315150352.sql
      1  with dates as (
      2     select to_date(:begin_date, 'YYYY-MM-DD') + level - 1 as d
      3     from dual
      4     connect by level <= to_date(:end_date, 'YYYY-MM-DD') - to_date(:begin_date, 'YYYY-MM-DD') + 1
      5  )
      6  select dates.d
      7  , r.rate
      8  from dates
      9  , ratemast r
    10* where dates.d between r.begindate and r.enddate
    [email protected](152)> /
    D               RATE
    09-DEC-06        750
    10-DEC-06        750
    11-DEC-06        950
    12-DEC-06        950
    13-DEC-06        950
    Elapsed: 00:00:00.02
    [email protected](152)> ed
    Wrote file TEST.BRANDT_152_20070315150352.sql
      1  with dates as (
      2     select to_date(:begin_date, 'YYYY-MM-DD') + level - 1 as d
      3     from dual
      4     connect by level <= to_date(:end_date, 'YYYY-MM-DD') - to_date(:begin_date, 'YYYY-MM-DD') + 1
      5  )
      6  select :begin_date
      7  , :end_date
      8  , avg(r.rate) as fee
      9  from dates
    10  , ratemast r
    11  where dates.d between r.begindate and r.enddate
    12* group by :begin_date
    [email protected](152)> /
    :BEGIN_DATE                      :END_DATE                               FEE
    2006-12-09                       2006-12-13                              870
    Elapsed: 00:00:00.01
    [email protected](152)> exec :end_date := '2007-01-15';
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    [email protected](152)> @ed
    Wrote file TEST.BRANDT_152_20070315151840.sql
      1  with dates as (
      2     select to_date(:begin_date, 'YYYY-MM-DD') + level - 1 as d
      3     from dual
      4     connect by level <= to_date(:end_date, 'YYYY-MM-DD') - to_date(:begin_date, 'YYYY-MM-DD') + 1
      5  )
      6  select dates.d
      7  , r.rate
      8  from dates
      9  , ratemast r
    10* where dates.d between r.begindate and r.enddate
    [email protected](152)> /
    D               RATE
    09-DEC-06        750
    10-DEC-06        750
    11-DEC-06        950
    12-DEC-06        950
    13-DEC-06        950
    14-DEC-06        950
    15-DEC-06        950
    16-DEC-06        950
    17-DEC-06        950
    18-DEC-06        950
    19-DEC-06        950
    20-DEC-06        950
    21-DEC-06        950
    22-DEC-06        950
    23-DEC-06        950
    24-DEC-06        950
    25-DEC-06        950
    26-DEC-06       1500
    27-DEC-06       1500
    28-DEC-06       1500
    29-DEC-06       1500
    30-DEC-06       1500
    31-DEC-06       1500
    01-JAN-07       1500
    02-JAN-07       1500
    03-JAN-07       1500
    04-JAN-07       1500
    05-JAN-07       1500
    06-JAN-07       1500
    07-JAN-07       1500
    08-JAN-07       1500
    09-JAN-07       1500
    10-JAN-07       1500
    11-JAN-07       1500
    12-JAN-07       1500
    13-JAN-07       1500
    14-JAN-07       1500
    15-JAN-07       1500
    38 rows selected.
    Elapsed: 00:00:00.01
    [email protected](152)> ed
    Wrote file TEST.BRANDT_152_20070315150352.sql
      1  with dates as (
      2     select to_date(:begin_date, 'YYYY-MM-DD') + level - 1 as d
      3     from dual
      4     connect by level <= to_date(:end_date, 'YYYY-MM-DD') - to_date(:begin_date, 'YYYY-MM-DD') + 1
      5  )
      6  select :begin_date
      7  , :end_date
      8  , avg(r.rate) as fee
      9  from dates
    10  , ratemast r
    11  where dates.d between r.begindate and r.enddate
    12* group by :begin_date
    [email protected](152)> /
    :BEGIN_DATE                      :END_DATE                               FEE
    2006-12-09                       2007-01-15                       1243.42105
    Elapsed: 00:00:00.01
    [email protected](152)> cheers,
    Anthony

  • Breaking Date Range in Query...

    Hi Friends,
    I have a Table which calculates Leaves taken by employees. The Leave Start date and End Date is in Range. i.e. Leave is from say 10th March 2006 to 15th March 2006. I need to generate a report for each day of the Leave. I.e. report needs a record for 10th, 11th,12th,13th,14th,15th. How can I break the date range into individual dates betn that range in a SQL Query..?
    thanks a lot,
    Jalpan Pota

    You can do it with a pipelined function. I have posted Re: Quarters Missing.?? that produces a range of quarters for a given date range. You should be easily able to amend this so that it produces a range of dates. Note that you will need to create a type that is a nested table of dates.
    Cheers, APC

  • Date range windowing query...I think

    Trying to do something I've not done before perhaps you can help or point me in the right direction.
    I've got a simple table with events, something like name, start_date, end_date. These events can be duplicates, they can be distinct, they can have the same start_date and different names, or they can have the same name and start_date but different end_dates - any kind of overlap is allowed. There can also be gaps in the events where there is no event that covers a particular date. Really the only thing I can count on is that none of the values will be null. Basically a mess, as far as determining into which event's start-end date range a particular date falls, when there is overlap. However, that's what I need to do. The other wrinkle is that it's okay for me to ignore the end date of an event, for the purposes of gap-filling. That is to say, if there is no event that covers Jun 1, 2010, then I can 'choose' the event that ends prior to Jun 1, 2010.
    I would like to, assuming some analytic function magic that I don't have, take this table and produce another that recomputes the start and end dates so that there is no overlap and the gaps are filled. As an overly simplistic example, given the input:
    name start end
    foo1 jan 1 jan 31
    foo2 jan 15 jan 31
    foo3 mar 1 mar 30
    it would generate
    foo1 jan 1 feb 28
    foo3 mar 1 mar 30
    or, alternatively
    foo1 jan 1 jan 14
    foo2 jan 15 feb 28
    foo3 mar 1 mar 30
    almost any reasonable elimination of overlaps is okay, so long as it makes sense. Are there any of the analytic functions that make this less painful?

    I'm not sure what the PK of your table is and how "funny" the data can get, but your second result can be got by this:
    create table test1 (
    name varchar2(10),
    startd date,
    endd date);
    insert into test1 values('foo1', to_date('20100101','yyyymmdd'),to_date('20100131','yyyymmdd'));
    insert into test1 values('foo2', to_date('20100115','yyyymmdd'),to_date('20100131','yyyymmdd'));
    insert into test1 values('foo3', to_date('20100301','yyyymmdd'),to_date('20100330','yyyymmdd'));
    commit;
    select name,to_char(startd,'mon dd') startd,
    to_char(lead(startd -1,1,endd) over (order by startd),'mon dd')endd
    from test1
    order by startd;
    or, alternatively
    foo1 jan 1 jan 14
    foo2 jan 15 feb 28
    foo3 mar 1 mar 30foo1     jan 01     jan 14
    foo2     jan 15     feb 28
    foo3     mar 01     mar 30
    - andy

  • Input date range on Query

    Hi Experts,
    I have a query that a client want as a Dashboard report. For this report to work in the Add-on, I cannot speficy it like this:
    T1.RefDate >= [%0] AND T1.RefDate <= [%1]
    Here is the Query they need this for:
    SELECT SUM(T0.SYSDeb - T0.SYSCred) AS 'Production'
    FROM JDT1 T0
    WHERE T0.Account in ('_SYS00000000238','_SYS00000000239','_SYS00000000244')
    UNION
    SELECT SUM(T0.SYSDeb - T0.SYSCred) AS 'Production'
    FROM JDT1 T0
    WHERE T0.Account = '_SYS00000000053'
    They want this to display for the curent month and have another that shows this for the past month.
    Any help would be appreciated.
    Marli

    Hi Marli,
    Try this for current month:
    SELECT SUM(T0.SYSDeb - T0.SYSCred) AS 'Production'
    FROM dbo.JDT1 T0
    WHERE T0.Account in ('_SYS00000000238','_SYS00000000239','_SYS00000000244',  '_SYS00000000053') AND
    MONTH(T0.RefDate)=Month(Getdate()) AND YEAR(T0.RefDate)=YEAR(Getdate()) 
    For last month, you just need change to MONTH(T0.RefDate)=Month(Getdate())-1
    Thanks,
    Gordon

  • Need to specify date range for query result.

    Below is my query. The query as is is working fine. The columns 'totalCalls' , 'totalOrders' and 'totalSCs' are all stored by date. I have created a form where the user can specify a start and end date. How would I change this query to report within those specified dates.
    <cfquery name="qZVPData_Western" datasource="xxxxxx">
    SELECT UserID,
           TMName,
        UserZone,
        AVG(WeekCallGoal) AS WCG,
        AVG(QTCallGoal) AS QTCG,
              (SELECT COUNT(*)
               FROM Sales_Calls
               WHERE Sales_Calls.UserID = u.UserID) as totalCalls,
        (SELECT COUNT(*)
         FROM Orders
         WHERE Orders.UserID = u.UserID) as totalOrders,
        (SELECT SUM(Quantity)
         FROM ProductOrders PO
         WHERE PO.UserID = u.UserID AND PO.NewExisting = 1) as newItems,
        (SELECT SUM(NewExisting)
         FROM  ProductOrders PO_
         WHERE PO_.UserID = u.UserID) as totalNew,
        (SELECT COUNT(ServiceCall_ID)
         FROM  ServiceCalls SC
         WHERE SC.UserID = u.UserID) as totalSCs,
        (SELECT COUNT(UserID)
         FROM  TMStatusLog TSL
         WHERE TSL.UserID = u.UserID AND TSL.Status = 'Vacation') as TSLdays1,
        (SELECT COUNT(UserID)
         FROM  TMStatusLog TSL
         WHERE TSL.UserID = u.UserID AND TSL.Status = 'TradeShow') as TSLdays2,
        (SELECT COUNT(UserID)
         FROM  TMStatusLog TSL
         WHERE TSL.UserID = u.UserID AND TSL.Status = 'Admin Day') as TSLdays3,  
        SUM(TSLdays1)+(TSLdays2)+(TSLdays3) AS TSLdays,   
        SUM(totalOrders)/(totalCalls) AS closePerc,
        SUM(totalOrders)/(totalCalls) - (.30) AS GRV,
        SUM(totalSCs)+(totalCalls)-(QTCG) AS PerVar,
       (SUM(totalSCs) + totalCalls + (TSLdays*WCG/5))/QTCG AS PerCalls
    FROM Users u
    WHERE UserZone = 'Western'
    GROUP BY UserZone, UserID, TMName
    </cfquery>
    I figured I could add this to the columns WHERE statements;
    'AND Column BETWEEN #FORM.Start# AND #FORM.End#' but this isn't working.
    Any ideas???

    What is the SQL being generated by your <cfquery> contents?  Is it valid SQL?  This is always the first thing to check when you get SQL errors back from the DB... check what you're sending to the DB.
    Second: don't hard-code dynamic values into your SQL string, pass them as parameters.
    Re all the subqueries: it runs fine in dev. Have you tried to load test it?  If poss move your subqueries to the FROM statement, as then they're only run once per recordset. As opposed to once per row of the result set, when the subqueries are in the SELECT or WHERE statement.
    Adam

  • SQL Syntax for hour/date range in Query

    Hi
    I am trying to set up an query for sales order documents procesed in the last 30 minutes to be set as an alert to be run every 30 minutes to the sales manager.  I am having difficulty getting the syntax for the last 30 minutes
    Any suggestions?
    David

    hi,
    I'm not sure query is correct,but u can modify it futher to get correct one.
    SELECT T0.DocNum, T0.DocDate, T0.CardName, T0.DocTotal FROM ORDR T0 WHERE DateDiff(dd, T0.DocDate ,getdate()) = 0 and
    DateDiff(Minute,T0.DocTime,' ') <= 30
    Jeyakanthan

  • Date Range Parameter's Restriction

    Could you someone please tell me how BO restricts date range parameter when the users tries to run a query?  Often times, users simultaneously try to get several years of data dumped into a single query.  Some users even forget to enforce the date range, which causes the query to try to get the data from the beginning of time. 
    How do we as a BO developer create some sort of date range restriction so that it can prevent users from overloading a query?  If the users want to get several years of data, he/she has to run a query in batches instead of doing it all at once.
    I hope there is a way that we can create a custom informational error message for each report to prevent users from trying to query too many months or years of data.  Some reports may hit small and well-indexed tables that allow large date range queries.  But, some reports query against large and poorly indexed tables, which can potentially cause adverse effect on performance without date range restriction. 
    Any thoughts or advices on how to implement such things (if possible).  I am also afraid that the answer will be "currently not doable".  If so, any ideas if the next version of BO will allow such functionality, or if it is at least in the plan at all?  Thank you so much for your insight and sharing.  Have a great day!

    Dear Amr,
    Thanks so much for your quick reply!  The field I want to create a restriction on is called RESULT_DT_TM.  When I saw the "where" section of the field, I just don't see how I can apply my START_DT_TM and END_DT_TM parameters on this field so that START_DT_TM and END_DT_TM cannot be more than 365 days apart.  If my query does not use parameters called START_DT_TM and END_DT_TM, this "where" section will not be valid? 
    I don't think the solution has to be on the field itself but rather on the parameter START_DT_TM and END_DT_TM.  What I want is that as long as START_DT_TM and END_DT_TM are more than 365 days apart, it does not matter what field these parameters are running against. The screen would then display something saying "your date range parameters for this report must be within 365 days.  Please revise your date range on query".
    Sorry, I am PL/SQL report programmer, and not familiar with what BO can do.  So, is there anyway that can make my dream come true?  Thanks a bunch again, Amr.

  • Display of 2 rows of data for 2 different date range selection

    Hi Folks,
    I have a requirement as follows,
    User has an option of selecting 2 Date Ranges
    From and To Date and again From and To Date
    The result should display 2 different rows of data with From and To Date range selection.
    Eg:
    12/09/20008 to 03/09/2009           10 20 30 40
    23/10/2009 to  18/12/2010           40 20 10 30
    Difference                                   30 0  20 10
    % Change                                   x  y  z   q
    Thanks for your input.
    Regards,
    KJ

    You will need to use union report, and you would have fours union's in this report.
    Union - 1: Data from 1st Date Range
    Union - 2: Data from 2nd Date Range
    Union - 3: Variance Calculation
    Union - 4: Percentage Variance Calculation.
    If the date's are coming from the same field, use cast function to use the same column twice in your prompts. Apply filters on each union as needed.
    Thanks.

  • Date Ranges Query

    Hi Experts,
    A very happy new year to all of you(to some in advance)!!
    I have a table where I have the employee id and task assigned with start dates & end dates. Overlapping dates of tasks is a data issue however I know how to spot them & eradicate them. So there will be no overlapping task dates
    Employee_id
    Task_No
    Task_Start_date
    Task_End_Date
    Sample Data
    1     T1     01-Jan-2014     28-Feb-2014
    1     T2     01-Mar-2014     31-Dec-2014
    2     T1     23-Jan-2014     31-Dec-2014
    2     T2     01-Jan-2015     31-Dec-2073 (Means end of time)
    3     T3     01-Jan-2014     15-Jul-2014
    3     T4     01-Aug-2014     31-Dec-2014
    4     T5     01-Jan-2014     31-Dec-2073
    I want to devise a query where i provide the end date & it will list out all the employees who are free for even one day starting 01-Jan-2014. So for example If I give 31-Dec-2014, it will list out
    EmpId     (First day on which the employee is free)
    2               01-Jan-2014
    3               16-Jul-2014
    If I give end date = end of time(31-Dec-2013), Expected Result -
    EmpId     (First day on which the employee is free)
    1               01-Jan-2015
    2               01-Jan-2014
    3               16-Jul-2014
    If I give end date = 31 Jan 2014, Expected Result -
    EmpId     (First day on which the employee is free)
    1               01-Jan-2015
    I devised following query, however it does not catch employee id 2. Also it does not provide flexibility to change end date-
    select *
      from (select employee_id,
                   task_start_date,
                   task_end_date,
                   lag(task_end_date, 1, task_start_date) over(partition by employee_id order by task_start_date) prev_end_date
              from shop.employee_tasks
             where task_end_date >= trunc(sysdate))
    where task_start_date - prev_end_date > 1
    Thanks in advance!!
    Regards,

    This is an example of what I call the "free time" query: you have the dates when you are busy and you want the dates when you are free.
    You can find a beautiful solution to the basic problem here: Ask Tom "SQL Query to find gaps in date ranges" (search for Antony Boucher's solution). Please note that this solution works even with overlapping date ranges.
    To apply the solution here, first create the test data (please do this yourself in later questions).
    create table t(Employee_id, task_no, Task_Start_date, task_end_date)
    as select
    1, 'T1', to_date('01-jan-2014'), to_date('28-feb-2014') from dual union all select
    1, 'T2', to_date('01-Mar-2014'), to_date('31-Dec-2014') from dual union all select
    2, 'T1', to_date('23-jan-2014'), to_date('31-dec-2014') from dual union all select
    2, 'T2', to_date('01-jan-2015'), to_date('31-dec-2073') from dual union all select
    3, 'T3', to_date('01-jan-2014'), to_date('15-jul-2014') from dual union all select
    3, 'T4', to_date('01-aug-2014'), to_date('31-dec-2014') from dual union all select
    4, 'T5', to_date('01-Jan-2014'), to_date('31-Dec-2073') from dual;
    In the query, you have to add records for yesterday and for the "end date" you want. This allows you to find "free time" before and after the date ranges in your table.
    Now you partition by Employee_id and order by Task_Start_date. Using the max(task_end_date) analytic function, you get the latest end date up to now. Add 1 to this and you get the first free date (maybe). To make sure that date is free, it has to be before the next start date.
    variable end_date varchar2(64)
    exec :end_date := '31-Dec-2073';
    with boundaries as (
      select trunc(sysdate)-1 task_start_date, trunc(sysdate)-1 task_end_date from dual
      union all
      select to_date(:end_date)+1, to_date(:end_date)+1 from dual
    ), data as (
      select * from t
    where task_end_date >= trunc(sysdate)
      and task_start_date < :end_date
      union all
      select distinct a.employee_id, null, b.task_start_date, b.task_end_date
      from t a, boundaries b
    select employee_id, min(free_start) free_start
    from (
      select employee_id,
      max(task_end_date) over (partition by employee_id order by task_start_date)+1 free_start,
      lead(task_start_date) over (partition by employee_id order by task_start_date)-1 free_end
      from data
    where free_start <= free_end
    group by employee_id;
    EMPLOYEE_ID
    FREE_START
    1
    01-JAN-15
    2
    01-JAN-14
    3
    16-JUL-14

Maybe you are looking for

  • How to get the position of a selected cell in a table without using the mouse event?

    Dear All,     I have a question about table:After clicking the cell of a table, the cell is into the edit status. How to know the row number and column number of the cell, when I click a button?    The link below is using the mouse down event:    htt

  • How to Save Camera Raw Changes?

    Hi all, First time poster here so please forgive my likely ignorance of Bridge's brilliant features.  I have just started to use Bridge as my primary tool in my post-processing workflow.  As I started going through a job I completed recently I starte

  • Issue with Document from Template

    Hi Friends,   I am using a Document from Template step to display a set of records in my Workflow. For this i have a created a template of type excel sheet and i have linked the multi line container element from my workflow to this template. But i am

  • F4 help for a selection screen parameter with filename created dynamically

    Hi All,           I have a requirement where in an F4 help should be present for a selection screen parameter. After selecting the filepath and clicking OK button on the Dialog, the filename should be dynamically get created in the selection screen p

  • Can you set security on Collab folders or just projects?

    I know this is the Content Services forum, but I couldn't find a forum for Collab. Anyone know if you can set security to the folder level in Collab 4.0.2 or can you only set it to the project level?