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

Similar Messages

  • 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

  • Max date data between the input date range.

    Hi
    I need to get the maximum date data's with in the date range.
    Ex: this is sample date but , total records in DB around 2000.
    NAME DATE Product1 Product2
    aaaa 01/05/2011 5 5
    aaaa 03/05/2011 3 3
    bbbb 04/05/2011 6 6
    bbbb 07/05/2011 2 2
    aaaa 06/05/2011 1 1
    case :1) If the user input date is 01/05/2011 to 05/05/2011
    then the result should be
    aaaa 3 3
    bbbb 6 6
    case :2) If the user input date is 01/05/2011 to 10/05/2011
    then the result should be
    aaaa 1 1
    bbbb 2 2
    so my result is purely based on max date between the input date range.
    how to achieve the result

    Dhiva wrote:
    Hi
    I need to get the maximum date data's with in the date range.
    Ex: this is sample date but , total records in DB around 2000.
    NAME DATE Product1 Product2
    aaaa 01/05/2011 5 5
    aaaa 03/05/2011 3 3
    bbbb 04/05/2011 6 6
    bbbb 07/05/2011 2 2
    aaaa 06/05/2011 1 1
    case :1) If the user input date is 01/05/2011 to 05/05/2011Jan 05 to May 05
    or
    May 01 to May 05
    what date is 07/08/09?

  • 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 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

  • 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 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

  • 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

  • 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

  • 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

  • Query for aggregates for each date in a date range

    Hi,
    I want to generate a Trend report with a T-SQL proc, which needs following logic. 
    Input -
    Date Range say '10/10/12' to '20/10/12'  (Say to check the trend of Size of account in 20 days of Trend report)
    Account balance is captured randomly, (i mean not every day) 
    Table with date looks like this..
    --Account Balance Table
    CREATE TABLE AccBanalce (
    BranchId SMALLINT
    NOT NULL,
    AccId CHAR(9)
    NOT NULL,
    Amount DECIMAL(9,3)
    NOT NULL,
    SnapShotDate DATETIME
    NOT NULL 
    CONSTRAINT PK_AccBanalce PRIMARY KEY NONCLUSTERED (AccId, SnapShotDate) )
    GO
    Create CLUSTERED INDEX CIx_AccBanalce ON AccBanalce (SnapShotDate)
    GO
    --Date Range table
    CREATE TABLE DateRange ( StartDate DATETIME, EndDate DATETIME)
    GO
    --Date for the Account Balance Table
    INSERT INTO AccBanalce (BranchId, AccId, Amount, SnapShotDate)
    VALUES (1, 'C1-100',  10.4, '10/11/2010' ),
    (1, 'G1-110',  20.5, '10/11/2010' ),
    (2, 'GC-120',  23.7, '10/11/2010' ),
    (2, 'Gk-130',  78.9, '10/13/2010' ),
    (3, 'GH-150',  23.5, '10/14/2010'),
    (1, 'C1-100',  31.8, '10/16/2010' ),
    (1, 'G1-110',  54.8, '10/16/2010' ),
    (2, 'GC-120',  99.0, '10/16/2010' ),
    (3, 'Gk-130',  110.0, '10/16/2010' ),
    (3, 'G5-140',  102.8, '10/16/2010' ),
    (2, 'GC-120',  105,  '10/18/2010' ),
    (2, 'Gk-130',  56.7, '10/18/2010' ),
    (1, 'C1-100',  84.3, '10/18/2010' ),
    (1, 'G1-110',  75.2, '10/19/2010' ),
    (2, 'GC-120',  64.9, '10/20/2010' ),
    (3, 'GH-150',  84.0, '10/20/2010' ),
    (1, 'C1-100',  78.0, '10/20/2010' ),
    (1, 'G1-110',  89.5, '10/20/2010' )
    GO
    --Date for DateRange Table
    INSERT INTO DateRange (StartDate, EndDate) VALUES
    ('2010-10-11 00:00:00.000', '2010-10-11 23:59:59.997'),
    ('2010-10-12 00:00:00.000', '2010-10-12 23:59:59.997'),
    ('2010-10-13 00:00:00.000', '2010-10-13 23:59:59.997'),
    ('2010-10-14 00:00:00.000', '2010-10-14 23:59:59.997'),
    ('2010-10-15 00:00:00.000', '2010-10-15 23:59:59.997'),
    ('2010-10-16 00:00:00.000', '2010-10-16 23:59:59.997'),
    ('2010-10-17 00:00:00.000', '2010-10-17 23:59:59.997'),
    ('2010-10-18 00:00:00.000', '2010-10-18 23:59:59.997'),
    ('2010-10-19 00:00:00.000', '2010-10-19 23:59:59.997'),
    ('2010-10-20 00:00:00.000', '2010-10-20 23:59:59.997')
    GO
    Question - 
    I want TOTAL Balance of all Accounts in a Branch per each day between 10/11/2010 to 10/20/2010
    If the Snapshotdate (date) on which the account was not made an entery to AccBalance table, last available  balance to be considered for that account.
    like for account [C1-100] on 10/15/2010 the balance should be [10.4]
    --Group By Branch
    --Last valid Account balance to be considered.
    I know, this is long solution, but any one who is expert in T-SQL can help me in this solution.
    Thanks,
    Krishna

    Thanks Himanshu You almost solved my issue...but can you provide the final output as following...
    Actually you are aggregating the Amount, which is not required, as it is the total available in that account.
    But the missing pint is I need the SUM of all the accounts for each DAY in a BRANCH.
    The 3rd Result Query modified to get DAILY balances for each account as following...
    --*RESULT*
    SELECT a.AccId, a.StartDate, 
                        (SELECT TOP 1 b.Amount
                        FROM #InterimOutput b
                        WHERE b.AccId = a.AccId and b.Amount > 0
                        AND B.StartDate<=A.StartDate  ORDER BY B.StartDate DESC) as ToDateBal
    FROM   #InterimOutput a
    ORDER BY a.AccId
    go
    Now I need SUM of all Account Balances AT each BRANCH on DAILY basics. Can you help on that?
    Thanks again
    Krishna

  • Two Date Characteristics As An OR Condition For Date Range Input

    Hello,
    Here's the requirement.  The user inputs a date range.  In the query, we have two date characteristics.  If at least one of the date characteristics falls between the inputted date range, then the row should show up on the report.  This is essentially an OR condition.  How can this be done?
    Thanks!

    hi,
    just a tought... but worth a try.
    1) Create an 2 Formula variables with User Exit.(ZF1 & ZF2)
    2) These will be filled with data with SETP2(User Exit) from the user Entry Variable. One variable will have from date & the next one will have to date.
    3) Then create 2 more Formula variables (ZR1 & ZR2) this time with replacement path for the 2 date you have and the create a global Key Figure with If Condition.
    CKF's:
    (( ( ZR1 >= ZF1) AND ( ZR1 <= ZF2 ) ) * (your vales)
    repeat the same for the ZR2 also.
    Regards, Siva

  • Date Ranges: Page Items or 'Input Parameters'?

    Hi,
    What is the best way to implement an user input date range qualifier in worksheets?
    So far I've only been able to achieve this by using item classes on a date field. Very messy.
    Anyone else doing this?

    Thanks Gveeden.
    How do you setup your date parameters?
    Are they 'conditions'? If so, how do you let the Users specify values in User Edition?
    Hope you can help out.
    Thanks already,
    Peter Verhoeven.

Maybe you are looking for

  • How do I get my old iPhone info onto my new one?

    The new iPhone is already activated as a new iPhone and I didn't want that!

  • Complete loss of tab order in form

    I received a MS Word document (2003) that I opened in my MS Word 2010 and saved as a .pdf document.  I then opened the .pdf file in Acrobat Pro v 9.4.7 and used the Forms tools to create a fillable form.  My tab order shows exactly as I want it to pe

  • 3D graphs cause LabVIEW 2010 to hang

    I've been using LabVIEW  2010 for several weeks without any problems, but today I noticed that it doesn't work at all with anything related to the 3D picture control. Today was the first time that I tried doing anything with the 3D picture tool sinc

  • How to use help in oracle 10g XE

    Hello, I just wanted to know how to use help in sql command line in oracle 10g XE regards, Sreekanth.

  • Planni values at cost element group level instead of at cost element level

    Is it possible to plan values at cost element group level instead of at cost element level in BI? Similary I have another question for financial statements. Is it possible to plan values at financial statement level instead of at G/ in BPS or SEM? Th