MTD,YTD,PTD without calendar table

          QTY
      Month
      Year
QTY_YTD
QTY_MTD
QTY_PTD
10
1
2010
20
2
2010
20
1
2012
30
3
2012
Above is how my table looks like and  all are having integer datatypes
I dont have a calendar table to join hence without calendar table can I compute YTD,MTD,PTD?
If so what will be the case queries
Mudassar

Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
This is minimal polite behavior on SQL forums. 
Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
The report period table gives a name to a range of dates that is common to the entire enterprise. 
CREATE TABLE Something_Report_Periods
(something_report_name CHAR(10) NOT NULL PRIMARY KEY
   CHECK (something_report_name LIKE <pattern>),
 something_report_start_date DATE NOT NULL,
 something_report_end_date DATE NOT NULL,
  CONSTRAINT date_ordering
    CHECK (something_report_start_date <= something_report_end_date),
etc);
These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • Split date range without Calendar table

    Hi guys!
    Is there any way to split date ranges (to days / hours / minutes) in one table without using Calendar table (without joining 2 tables)?
    Reason I'm asking this is because we have a huge Fact table (500+ million records) and joining small Calendar table and this huge Fact table takes considerable amount of time.
    So far we tried:
    Join 2 tables (Fact and Calendar)
    Cross Applying Calendar and table-valued function (that returns necessary measures from Fact table)
    and both approaches took few minutes for 1 day to complete.
    Most successful test we had so far was using CLR and executing table-valued functions in parallel for different 15 minute periods. This way we were able to get the results in 3-4 seconds.
    Anyway, is there any effective pure T-SQL way to accomplish this?
    Thanks in advance,
    Miljan

    Try using a temporary table rather than table variable.. You can have a CI on the date column.
    or
    declare @PeriodStart datetime2(0) = '2013-01-05 00:00:00'
    declare @PeriodEnd datetime2(0) = '2013-01-05 02:00:00'
    select T.PeriodStart, T.PeriodEnd, count(Column1)as count1, sum(Column2)as sum1
    from Fact F with(nolock)WHERE F.[Start]>= '19000101' AND <=@PeriodStartand F.[End] >= @PeriodEnd and F.[End] <='20200101'
    group by T.PeriodStart, T.PeriodEnd
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Last Year MTD/YTD Column Without Using Time Series Function

    I need to calculate MTD and YTD of last year without using time series function.
    My requirement is like:
    We are working on Fiscal year.
    Suppose user will select a date: 15-Jan-2013

    Use a period table with Period Ago attributes and join these to an alias of your fact table. In other words, use a period table (let's say Day is grain) that would have
    WAgo, QAgo, YAgo, (etc.) attributes for each day. Join this table to aliases of the fact tables on these columns.
    Thanks.

  • Date Based Dynamic Member Calculation Performance (MTD, YTD, PeriodsToDate)

    I'm working on an SSAS 2012 cube and I have defined several dynamic calculations based on a Date (MTD, YTD, TD, Thru Previous Month, etc.).
    The cube has a well defined Date dimension and I have set up a DYNAMIC calculated set in the cube as shown below.
    CREATE DYNAMIC SET CURRENTCUBE.[Latest Date]
    AS TAIL(EXISTS([Payment Date].[Calendar Date].[Date].Members,[Payment Date].[Calendar Date].CURRENTMEMBER,"Claim Payment"));
    ... and here is an example of one of my calculations.
    CREATE MEMBER CURRENTCUBE.[Measures].[Face Amount Paid MTD]
    AS SUM(MTD([Latest Date].ITEM(0).ITEM(0)), [Measures].[Face Amount Paid]),
    FORMAT_STRING = "$#,##0.00;-$#,##0.00",
    //NON_EMPTY_BEHAVIOR = { [Claim Payment Fact Count] },
    VISIBLE = 1 , DISPLAY_FOLDER = 'Face Amount' , ASSOCIATED_MEASURE_GROUP = 'Claim Payment';
    This calculation returns the correct results, but performs horribly.  I've noticed that changing the [Latest Date] set to STATIC, performance greatly improves, but numbers are no longer accurate as they are based on the Tail of the Claim Payment measure
    group without considering the filtered dates.  This is because the date is evaluated at process time, but needs to be based on users date selection to be accurate.  Therefore, STATIC does not appear to be an option.  Is there a better way to
    perform this calculation dynamically based on the filtered or unfiltered date dimension?

    Typically I would just do YTD/MTD/etc off the date the user has selected.  It seems like you want to do it based on the last date with data within the range they have selected.  Why not just give the user what they are asking for?
    In other words, why not
    YTD([Payment Date].[Calendar Date].currentmember)

  • Calendar Table Population

    Hi
    I need to populate a calendar table with two fields date(for 10 yrs) and Holiday Flag.Holiday flag will be Y if its saturday and Sunday and N for weekdays.
    Can anyone please provide me with the script to populate the table.
    Thanks

    Hi Jameel,
    Well, when I said version dependant, the result can differ :
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.7.0 - Production
    SQL> select sysdate+rownum,
      2  decode(to_char(sysdate+rownum,'Dy'),'Sat','Y','Sun','Y','N')
      3  from dual connect by level<=10;
    SYSDATE+ D
    11/06/06 Y
    =================================================
      1  select sysdate+rownum,
      2  decode(to_char(sysdate+rownum,'Dy'),'Sat','Y','Sun','Y','N')
      3* from dual connect by level<=10
    SCOTT@demo102> /
    SYSDATE+ D
    11/06/06 Y
    12/06/06 N
    13/06/06 N
    14/06/06 N
    15/06/06 N
    16/06/06 N
    17/06/06 Y
    18/06/06 Y
    19/06/06 N
    20/06/06 N
    10 rows selected.
    SCOTT@demo102> select * from v$version where rownum=1;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
    SCOTT@demo102> Without said about 10.1.0.2 (which I don't have) which give 11 rows with the same query above (see Re: Cube Function
    All these facts said me that we have to use others ways like pipelined (as showed the link I gave above) or dimension...
    Nicolas.

  • Please help me in Calculating Sybase IQ Daily,WTD,MTD, YTD,QTD,SPLM,SPLY

    Hi Team,
    Need to Calculate No of Customers from a particular dimension table on these measures Daily,WTD,MTD, YTD,QTD,SPLM,SPLY
    Can anybody help me with the Logic its extremely urgent.
    Thanks all for your help
    Regards,
    Yedu

    Is that part of an entire script, I don't see the tokens changing as TimG observed is this being called from a different routine. (are you calling the same script using a for loop?)
    I think instead of updating the subvar everytime, he just used a bat/sh script to run it for various members.
    Regards
    Celvin
    http://www.orahyplabs.com

  • SQL Query to calculate on-time dispatch with a calendar table

    Hi Guys,
    I have a query (view) to calculate orders' fulfillment leadtimes.
    The current criteria exclude week-ends but not bank holidays therefore I have created a calendar table with a column name
    isBusinessDay but I don't know how to best use this table to calculate the On-Time metric. I have been looking everywhere but so far I have been unable to solve my problem.
    Please find below the current calculation for the On-Time Column:
    SELECT
    Week#
    , ClntGroup
    , CORD_DocumentCode
    , DESP_DocumentCode
    , Cord_Lines --#lines ordered
    , CORD_Qty --total units orderd
    , DESP_Lines --#lines dispatched
    , DESP_Qty --total units dispatched
    , Status
    , d_status
    , OpenDate --order open date
    , DateDue
    , DESP_PostedDate --order dispatched date
    , DocType
    , [Lead times1]
    , [Lead times2]
    , InFxO
    , OnTime
    , InFxO + OnTime AS InFullAndOneTime
    , SLADue
    FROM (
    SELECT
    DATEPART(WEEK, d.DateOpn) AS Week#
    , Clients.CustCateg
    , Clients.ClntGroup
    , d.DocumentCode AS CORD_DocumentCode
    , CDSPDocs.DocumentCode AS DESP_DocumentCode
    , COUNT(CORDLines.Qnty) AS Cord_Lines
    , SUM(CORDLines.Qnty) AS CORD_Qty
    , COUNT(CDSPLines.Qnty) AS DESP_Lines
    , SUM(CDSPLines.Qnty) AS DESP_Qty
    , CDSPLines.Status
    , d.Status AS d_status
    , d.OpenDate
    , d.DateDue
    , CDSPDocs.PostDate AS DESP_PostedDate
    , d.DocType
    , DATEDIFF(DAY, d.OpenDate, d.DateDue) AS [Lead times1]
    , DATEDIFF(DAY, d.OpenDate, CDSPDocs.PostDate) AS [Lead times2]
    , CASE WHEN SUM(CORDLines.Qnty) = SUM(CDSPLines.Qnty) THEN 1 ELSE 0 END AS InFxO --in-full
    --On-Time by order according to Despatch SLAs
    , CASE
    WHEN Clients.ClntGroup IN ('Local Market', 'Web Sales', 'Mail Order')
    AND (DATEDIFF(DAY, d.OpenDate, CDSPDocs.PostDate) - (DATEDIFF(WEEK, d.OpenDate, CDSPDocs.PostDate) * 2 ) <= 2)
    THEN 1
    WHEN Clients.ClntGroup IN ('Export Market', 'Export Market - USA')
    AND (DATEDIFF(DAY, d.OpenDate, CDSPDocs.PostDate) - (DATEDIFF(WEEK, d.OpenDate, CDSPDocs.PostDate) * 2) <= 14)
    THEN 1
    WHEN Clients.ClntGroup = 'Export Market' OR Clients.CustCateg = 'UK Transfer'
    AND d.DateDue >= CDSPDocs.PostDate
    THEN 1
    ELSE 0
    END AS OnTime
    --SLA Due (as a control)
    , CASE
    WHEN Clients.ClntGroup IN ('Local Market', 'Web Sales','Mail Order') AND CDSPDocs.PostDate is Null
    THEN DATEADD(DAY, 2 , d.OpenDate)
    WHEN Clients.ClntGroup IN ('Export Market', 'Export Market - UK', 'Export Market - USA') OR (Clients.CustCateg = 'UK Transfer')
    AND CDSPDocs.PostDate IS NULL
    THEN DATEADD (DAY, 14 , d.OpenDate)
    ELSE CDSPDocs.PostDate
    END AS SLADue
    FROM dbo.Documents AS d
    INNER JOIN dbo.Clients
    ON d.ObjectID = dbo.Clients.ClntID
    AND Clients.ClientName NOT in ('Samples - Free / Give-aways')
    LEFT OUTER JOIN dbo.DocumentsLines AS CORDLines
    ON d.DocID = CORDLines.DocID
    AND CORDLines.TrnType = 'L'
    LEFT OUTER JOIN dbo.DocumentsLines AS CDSPLines
    ON CORDLines.TranID = CDSPLines.SourceID
    AND CDSPLines.TrnType = 'L'
    AND (CDSPLines.Status = 'Posted' OR CDSPLines.Status = 'Closed')
    LEFT OUTER JOIN dbo.Documents AS CDSPDocs
    ON CDSPLines.DocID = CDSPDocs.DocID
    LEFT OUTER JOIN DimDate
    ON dimdate.[Date] = d.OpenDate
    WHERE
    d.DocType IN ('CASW', 'CORD', 'MORD')
    AND CORDLines.LneType NOT IN ('Fght', 'MANF', 'Stor','PACK', 'EXPS')
    AND CORDLines.LneType IS NOT NULL
    AND d.DateDue <= CONVERT(date, GETDATE(), 101)
    GROUP BY
    d.DateOpn
    ,d.DocumentCode
    ,Clients.CustCateg
    ,CDSPDocs.DocumentCode
    ,d.Status
    ,d.DocType
    ,d.OpenDate
    ,d.DateReq
    ,CDSPDocs.PostDate
    ,CDSPLines.Status
    ,Clients.ClntGroup
    ,d.DocumentName
    ,d.DateDue
    ,d.DateOpn
    ) AS derived_table
    Please find below the DimDate table
    FullDateNZ HolidayNZ IsHolidayNZ IsBusinessDay
    24/12/2014 NULL 0 1
    25/12/2014 Christmas Day 1 0
    26/12/2014 Boxing Day 1 0
    27/12/2014 NULL 0 0
    28/12/2014 NULL 0 0
    29/12/2014 NULL 0 1
    30/12/2014 NULL 0 1
    31/12/2014 NULL 0 1
    1/01/2015 New Year's Day 1 0
    2/01/2015 Day after New Year's 1 0
    3/01/2015 NULL 0 0
    4/01/2015 NULL 0 0
    5/01/2015 NULL 0 1
    6/01/2015 NULL 0 1
    This is what I get from the query:
    Week# ClntGroup CORD_DocumentCode OpenDate DESP_PostedDate OnTime
    52 Web Sales 123456 24/12/2014 29/12/2014 0
    52 Web Sales 123457 24/12/2014 30/12/2014 0
    52 Web Sales 123458 24/12/2014 29/12/2014 0
    52 Local Market 123459 24/12/2014 29/12/2014 0
    1 Web Sale 123460 31/12/2014 5/01/2015 0
    1 Local Market 123461 31/12/2014 6/01/2015 0
    As the difference between the dispatched and open date is 2 business days or less, the result I expect is this:
    Week# ClntGroup CORD_DocumentCode OpenDate DESP_PostedDate OnTime
    52 Web Sales 123456 24/12/2014 29/12/2014 1
    52 Web Sales 123457 24/12/2014 30/12/2014 1
    52 Web Sales 123458 24/12/2014 29/12/2014 1
    52 Local Market 123459 24/12/2014 29/12/2014 1
    1 Web Sale 123460 31/12/2014 5/01/2015 1
    1 Local Market 123461 31/12/2014 6/01/2015 1
    I am using SQL Server 2012
    Thanks
    Eric

    >> The current criteria exclude week-ends but not bank holidays therefore I have created a calendar table with a column name “isBusinessDay” but I don't know how to best use this table to calculate the On-Time metric. <<
    The Julian business day is a good trick. Number the days from whenever your calendar starts and repeat a number for a weekend or company holiday.
    CREATE TABLE Calendar
    (cal__date date NOT NULL PRIMARY KEY, 
     julian_business_nbr INTEGER NOT NULL, 
    INSERT INTO Calendar 
    VALUES ('2007-04-05', 42), 
     ('2007-04-06', 43), -- good Friday 
     ('2007-04-07', 43), 
     ('2007-04-08', 43), -- Easter Sunday 
     ('2007-04-09', 44), 
     ('2007-04-10', 45); --Tuesday
    To compute the business days from Thursday of this week to next
     Tuesdays:
    SELECT (C2.julian_business_nbr - C1.julian_business_nbr)
     FROM Calendar AS C1, Calendar AS C2
     WHERE C1.cal__date = '2007-04-05',
     AND C2.cal__date = '2007-04-10'; 
    We do not use flags in SQL; that was assembly language. I see from your code that you are still in a 1960's mindset. You used camelCase for a column name! It makes the eyes jump and screws up maintaining code; read the literature. 
    The “#” is illegal in ANSI/ISO Standard SQL and most other ISO Standards. You are writing 1970's Sybase dialect SQL! The rest of the code is a mess. 
    The one column per line, flush left and leading comma layout tells me you used punch cards when you were learning programming; me too! We did wrote that crap because a card had only 80 columns and uppercase only IBM 027 character sets. STOP IT, it make you
    look stupid in 2015. 
    You should follow ISO-11179 rules for naming data elements. You failed. You believe that “status” is a precise, context independent data element name! NO! 
    You should follow ISO-8601 rules for displaying temporal data. But you used a horrible local dialect. WHY?? The “yyyy-mm-dd” is the only format in ANSI/ISO Standard SQL. And it is one of the most common standards embedded in ISO standards. Then you used crap
    like “6/01/2015” which is varying length and ambiguous that might be “2015-06-01” or “2015-01-06” as well as not using dashes. 
    We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. 
    And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> Please find below the current calculation for the On-Time Column: <<
    “No matter how far you have gone down the wrong road, turn around”
     -- Turkish proverb
    Can you throw out this mess and start over? If you do not, then be ready to have performance got to hell? You will have no maintainable code that has to be kludged like you are doing now? In a good schema an OUTER JOIN is rare, but you have more of them in
    ONE statement than I have seen in entire major corporation databases.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Creating Fiscal/Calendar Table

    Hello,
    Please, help to create a Fiscal and Calendar table with the following conditions:
    The table and the first fiscal year start from 01/31/2011
    The end date could be 12/31/2020 (not that important as it could be a smaller date)
    All the next fiscal years should start 52 weeks after on the following Monday.
    I’m trying to modify the following code that is calculating the beginning of the fiscal year with 52 weeks ahead but with following Monday only for the first next Fiscal Year.
    Thanks
    DECLARE
    @StartDate smalldatetime
    = '01/31/2011'
    --First Calendar date to include in table
    DECLARE
    @EndDate smalldatetime
    = '12/31/2020'
    --Last calendar date to include in the table
    declare
    @FiscalYearBegin_First smalldatetime
    = '1/31/2011'
    DECLARE
    @Cycle INT
    = 52
    SET
    DATEFIRST 7
     ;WITH
    --This secton generates the number table
    E00(N)
    AS (SELECT 1
    UNION ALL
    SELECT 1),
    E02(N)
    AS (SELECT 1
    FROM E00
    a, E00
    b),
    E04(N)
    AS (SELECT 1
    FROM E02
    a, E02
    b),
    E08(N)
    AS (SELECT 1
    FROM E04
    a, E04
    b),
    E16(N)
    AS (SELECT 1
    FROM E08
    a, E08
    b),
    E32(N)
    AS (SELECT 1
    FROM E16
    a, E16
    b),
    cteTally(N)
    AS (SELECT
    ROW_NUMBER()
    OVER (ORDER
    BY N)
    FROM E32),
    --This CTE generates a list of calendar dates
    CalendarBase
    as (
     SELECT
    DateKey =
    n
    , CalendarDate
    = DATEADD(day,
    n -1,
    @StartDate )
    case when n
    = 1 then
    @FiscalYearBegin_First 
    else
    case when
    datepart(dw,DATEADD(DAY,
    n -1
    , @StartDate ))
    = 2 then 
    dateadd(week,CAST(ABS(DATEDIFF(WEEK,DATEADD(day,
    n -1
    , @StartDate ),@StartDate))/@Cycle
    AS INT)
    * @Cycle,@FiscalYearBegin_First)
    else
    dateadd(week,
    datediff(week, 0,
    dateadd(week,CAST(ABS(DATEDIFF(WEEK,DATEADD(day,
    n - 1,
    @StartDate ),@StartDate))/@Cycle
    AS INT)
    * @Cycle,@FiscalYearBegin_First)), 7)
    end
    end FiscalYearBegin
    FROM cteTally
      WHERE
    N <=
    DATEDIFF(day,
    @StartDate ,
    @EndDate +1)
    --Finally, use the list of calendar dates to fill the date dimension
    SELECT
    DateKey
    , IsoDate      
    = CONVERT(char(8),
    CalendarDate, 112)
    , CalendarDate
    , CalendarYear 
    = YEAR(CalendarDate)
    , CalendarQuarter
    =  (DATEPART(QUARTER,CalendarDate)
    , CalendarMonth
    = MONTH(CalendarDate)
    , CalendarDay  
    = DATEPART(DAY,
    CalendarDate)
    , DayofWk      
    = DATEPART(Dw,
    CalendarDate)
    , CalendarWeekOfMonth
    = DATEDIFF(week,
    DATEADD(day,1,
    CalendarDate-DAY(CalendarDate)
    + 1)
    -1, CalendarDate)
    +1
    , WeekofYr     
    = DATEPART(WEEK,
    CalendarDate)
    , DayofYr      
    = DATEPART(DAYOFYEAR,
    CalendarDate)
    , NameMonth    
    = DATENAME(Month,
    CalendarDate)
    , NameDay      
    = DATENAME
    (Weekday,CalendarDate
    , FiscalYear   
    = YEAR(FiscalYearBegin)
    , FiscalMonth   
    = DATEDIFF(
    MONTH,
    FiscalYearBegin,
    CalendarDate) + 1
    , FiscalQuarter  
    = DATEDIFF(
    QUARTER,
    FiscalYearBegin,
    CalendarDate) + 1
    , FiscalWeek    
    = DATEDIFF(
    WEEK,
    FiscalYearBegin,
    CalendarDate) + 1
    , FiscalDay     
    = DATEDIFF(
    day,
    FiscalYearBegin,
    CalendarDate) + 1
    FROM
    CalendarBase

    Try the below code if this meets your requirement.
    DECLARE @StartDate DATETIME = '01-31-2011'
    ,@EndDate DATETIME = '12-31-2020'
    ;WITH cteCalendar (CurrentDate,WeekDay,DayNum,WeekNum)
    AS
    (SELECT @StartDate AS CurrentDate, DATENAME(WEEKDAY,@StartDate) AS WeekDay, 1 AS MonthCode, 1 AS WeekNum
    UNION ALL
    SELECT DATEADD(DD,1,cte.CurrentDate) AS CurrentDate, DATENAME(WEEKDAY,DATEADD(DD,1,cte.CurrentDate)) AS WeekDay, cte.DayNum + 1 AS DayNum
    , cte.DayNum / 7 + 1 as WeekNum
    FROM cteCalendar cte
    WHERE cte.CurrentDate + 1 <= @EndDate
    SELECT CurrentDate,WeekDay
    ,CASE WHEN WeekNum%52 = 0 THEN 52
    ELSE WeekNum%52 END AS WeekNumber
    ,DATEPART(YY,@StartDate) + (WeekNum - 1)/52 AS FiscalYear
    FROM cteCalendar
    OPTION (MAXRECURSION 0)
    Only year condition was mentioned and you didn't mention about month, so i did not consider month in the result set. If month is also required, share the condition (30Days in a month or 4Weeks in month?)
    Let me know if i got you wrong.

  • Add a new record in database table without using table maintance generator

    Hi Expart ,
                  Plz. tell me how to add new record in database table without using table maintance ganerator ....give me one ex.
    Regards
    Bhabani

    Hi,
    The other way to safely handle the modification of tables is through is by programs that can be done with SE38 or SE80.
    To insert into database table we use INSERT statement :
    1. To insert a single line into a database table, use the following:
    INSERT INTO <target> VALUES <wa>.
    INSERT <target> FROM <wa>.
    2. To insert a several lines into a database table, use the following:
    INSERT <target> FROM TABLE <itaba>.
    Or even we can use MODIFY statementas this single statement is used to insert as well as update the records of database table.
    MODIFY <target> FROM <wa>.
    or MODIFY <target> FROM TABLE <itab>.
    thanx.
    Edited by: Dhanashri Pawar on Sep 10, 2008 12:25 PM
    Edited by: Dhanashri Pawar on Sep 10, 2008 12:30 PM

  • Query (MTD/YTD/LYMTD/LYYTD)

    Hi All,
    I have to create a query and i got the requirement like this:
    4)     Key figures required are
    a.     Actual Consumption Qty / per MT (MTD/YTD/LYMTD/LYYTD)
    b.     Standard Consumption Qty / per MT  (CY/LY)
    c.     AOP Rate  (CY/LY)
    d.     AOP Value  (b X c)  (CY/LY)
    e.     Consumption Value  (MTD/YTD/LYMTD/LYYTD)
    f.     Actual Consumption Rate  (e / a) (MTD/YTD/LYMTD/LYYTD)
    g.     Rate Variance ((f u2013 d ) * a)     (MTD/YTD)
    h.     Usage Variance ((b u2013 a ) * c)  (MTD/YTD)
    i.     ETP Material Consumption    (MTD/YTD/LYMTD/LYYTD)
    j.     Packing Material Cost      (MTD/YTD/LYMTD/LYYTD)
    k.     Variable Overheads  (MTD/YTD/LYMTD/LYYTD)
    l.     Fixed Overheads (MTD/YTD/LYMTD/LYYTD)
    m.     AOP Output Qty (MTD/YTD/LYMTD/LYYTD)
    n.     Output Qty    (MTD/YTD/LYMTD/LYYTD)
    Can anybody expalin me what does mean by  (MTD/YTD/LYMTD/LYYTD)
    Do I have to create 4 different keyfigures for this ?
    Regards
    Shweta

    This means that you will have create a key figure whivch shows the valure like this
    Suppose you are giving a date as the input to the query...this input date can be any date like creation date of document or posting date of the any doc.
    Suppose user gave 04.12.2008 as the input
    MTD: Month till date
    This should show the value of any key figure for the month of the date which you have given till the day of the month.
    So it should give the values between 01.12.2008 till 04.12.2008 in the report for that key figure from the cube.
    YTD:Year till date
    This should give 01.01.2008 till 04.12.2008
    LYMTD:Last year month till date
    this can be 01.12.2007 till 04.12.2007
    LYYTD:Last year..year till date
    This can be 01.01.2007 to 04.12.2007
    Yes you will have create different RKF's for each of the key figure restricting them based on the requirement.
    Thanks
    Ajeet

  • Descriptor without a table

    Hello All,
    We are working on a project where we are analysing the pros and cons of using SQL Named Queries Vs Named Queries defined in Java.
    Can we define a Toplink Descriptor without a table definition (None of the fields are mapped). I was able to generate Deployment XML file, but the application failed at runtime saying "Descriptor must have a table name defined"
    Also, if ever that was possible, what are the implications of not mapping the the object to a table and just having Named SQL queries directly load into the Java objects.
    How do the update, insert and delete work in this scenario?
    Has anyone tried Custom SQLs/ SQL Named Queries?
    Thanks,
    Neeraj

    You need to map a class to a table. But, it doesn't have to be a "real" table. You can just fake one in the Mapping Workbench, and then if all your SQL overrides don't actually use that Table, no problems. We need to map to a table - if anything - to have a place to store column names that can be used to map the results of the SQL to the attributes in the class. I see this kind of thing when people want to map classes to stored procs. They fake a table in the MW, map the class to it, and then in all the CRUD overrides they put their stored proc calls and the results from the stored procs need to have "column" names that match those in the fake table.
    - Don

  • Designer generating CG_REF_CODES inserts without the table name.

    We have upgraded our repository from 9i to 10g and now when we generate DDL we get our insert statements for the CG_REF_CODES table without a table name. I am sure that this must be a setting somewhere but I can't find any reference to it in the help. The following is an example of the generated .avt file from our 10g installation.
    Thanks in advance,
    Chris S.
    DELETE FROM
    WHERE RV_DOMAIN = 'DURATION_VALUE'
    INSERT INTO (RV_DOMAIN, RV_LOW_VALUE, RV_HIGH_VALUE, RV_ABBREVIATION, RV_MEANING)
    VALUES ('DURATION_VALUE', 'D', NULL, 'Days', 'Days')
    INSERT INTO (RV_DOMAIN, RV_LOW_VALUE, RV_HIGH_VALUE, RV_ABBREVIATION, RV_MEANING)
    VALUES ('DURATION_VALUE', 'M', NULL, 'Months', 'Months')
    INSERT INTO (RV_DOMAIN, RV_LOW_VALUE, RV_HIGH_VALUE, RV_ABBREVIATION, RV_MEANING)
    VALUES ('DURATION_VALUE', 'Y', NULL, 'Years', 'Years')
    INSERT INTO (RV_DOMAIN, RV_LOW_VALUE, RV_HIGH_VALUE, RV_ABBREVIATION, RV_MEANING)
    VALUES ('DURATION_VALUE', 'B', NULL, 'Business Days', 'Business Days')
    INSERT INTO (RV_DOMAIN, RV_LOW_VALUE, RV_HIGH_VALUE, RV_ABBREVIATION, RV_MEANING)
    VALUES ('DURATION_VALUE', 'I', NULL, 'Indefinite', 'Indefinite')
    COMMIT
    /

    Sounds like a bug to me, but one thing you can check is the generator options that affect the reference code table. In the Design Editor select your application in the navigator, then the Options menu. Select "Generator Options...", then "General..."
    One thing you might fool with is the File Name Length restriction - mine is blank, but then I tend not to use CG_REF_CODES, so I haven't generated them for quite a while. Try setting it to 30, which would be the right number for Oracle, or to 0, which is supposed to mean "no restriction".

  • Export dump without some table

    i would like to export whole schema without few tables on oracle 10g. can someone advise me how can i do that. can someone give me the task.
    thanks

    You do the simpilar thing in original exp/imp, but only INCLUDE not exclude, see this example,
    %exp test/test1 tables=me% STATISTICS=NONE
    Export: Release 10.1.0.2.0 - Production on Mon Jan 7 10:15:32 2008
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    Export done in US7ASCII character set and AL16UTF16 NCHAR character set
    server uses WE8ISO8859P1 character set (possible charset conversion)
    About to export specified tables via Conventional Path ...
    . . exporting table                           ME22          4 rows exported
    . . exporting table                             ME          0 rows exported
    . . exporting table                            ME2          0 rows exported
    . . exporting table                            ME3          0 rows exported
    Export terminated successfully without warnings.
    sqlplus test/test1
    SQL*Plus: Release 10.1.0.2.0 - Production on Mon Jan 7 10:16:54 2008
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    TEST> select table_name from user_tables
      2  where table_name like 'ME%';
    TABLE_NAME
    ME
    ME2
    ME22
    ME3

  • If an employee changes Company code,how his YTD cumulations in CRT table calculates as per SAP Standards ?

    Hi All,
    Please help me out in understanding below scenario.
    If an employee changes from one company code to another code, how his/her YTD cumulates in CRT table as per SAP Standards.
    Let me go with example to make a clear understanding.
    Ex : Payroll has run for an employee upto payperiod 05. As per his pay assume that his /101 is 5000.
                             Monthly                  Yearly
    PP 1      :           5000                       5000
    PP 2      :           5000                      10000
    PP 3      :           5000                      15000         
    PP 4      :           5000                      20000
    PP 5      :           5000                      25000
    In PP 6 he has shifted from one company code to another company code. Now, how the system cumulates as per SAP standards ?
    PP 6       :           5000                        ?
    Will the amount nullifies or else adds to previous PP5  ?
    Thanks in Advance....

    Hi Ameet,
    I understood the same. But my client is asking that the amount should nullify in CRT table for yearly when an employee changes company code.
    And they have maintained different tax grouping for company codes in table v_t7ph0a. will that table makes any difference ?
    Regards,
    Nalini.

  • Export mailbox to pst from exchange 2010 shell - without calendar

    Is there a way to edit this command:
    New-MailboxExportRequest -Mailbox Kweku -IsArchive -FilePath "\\SERVER01\PSTFileShare\Kweku_Archive.pst"
    that it would export mailbox without calendars?
    with best regards,
    bostjanc

    You can use the -ContentFilter option to filter folders \ date
    Exchange Blog:
    www.ntweekly.com
    MCSA, MCSE, MCITP:SA, MCITP:EA, MCITP:Enterprise Messaging Administrator 2010,MCTS:Virtualization

Maybe you are looking for

  • Mail won't open - please help me if you can I'm feeling down .... and I do

    Hello everyone - never used this before so I don't know quite where it will arrive - BUT, HELP - my Mail program just will not load - I press the icon in the sidebar and it just hops and that's it! I hold the menue open and click 'open' and the same,

  • Ipod wont start up after 5.1.1 update

    after updateing to new version of itunes and to ios 5.1.1 my ipod wont boot up all i get is a black screen with white spining clock, computer finds the device and so does itunes but its not leting me restore to an back up or factory settings as itune

  • Flash Player is NOT working in Firefox

    I have installed Flash Player recently on Windows 7. It is working properly i.e. playing vidoes on IE & Chrome but not in Firefox. I have updated both Flash Player & Firefox but it is still not playing any videos. Please solve this for me.

  • Returning multiple values problem. ParameterMode.OUT / getOutputParams

    Hi, Please help me on this. I think that this should be plain and simple but it is not. The code below will have an error... ">> unexpected element name: expected=wsdldata2, actual=wsdldata1" I use TCPmon to monitor the Soap Request and Response... t

  • Newb -- Changing the name of a Theme...?

    I have a theme which I am using called "Revolution" (ver 7.0.3). The title "Revolution Main" revolves around a photo at the centre. How can I change the "Revolution Main" text to something else? Thanks,,