Previous day date to pick up

i want to pick up the previous latest date from a column. that means
if i have a column name batch_id and the dates avaiable are
batch_id Previous date
27-06-07 26-06-07
26-06-07 25-06-07
25-06-07 23-06-07 -----saturday date out here
Its a sunday therefore no business for this day and therefore no entry for this day.
23-06-07 22-06-07
please let me know how to achive this through SQL
Thanks in advance

Is this?
select batch_id
  ,case when to_cahr(batch_id,'fmday','nls_date_language=american') = 'monday'
    then batch_id-3
    else batch_id-1
   end  previous_date
from your_table
;But, how do you want to treate holidays?

Similar Messages

  • How to get previous day data if i dont have current day data.

    Hello Gurus,
    I have a stock levels data in ODS. when there is no movements, we are not getting any stocks into ODS. So we have to get previous day data as it is for current day data into another ODS.
    Could you please help me in this regard.
    Thanks in advance,
    Rama

    Rama -    
            0CALDAY can't help us in this scenario .
    Step 1 :
        To do this - You have to add one ZDATE (InfoObject ) to 1st ODS. ZDATE is updated by itself from current date of system  when ever you are loading data to 1st ODS.
    Step 2:
       You have to do full update to 2nd ods.At the selection screen of InfoPackage  (from 1st ODS to 2nd ODS ) you have to write following code for ZDATE.
    pseudo Code:
    1) Select fields "Rec_INSERT","Time stamp","Request Status" and "Request ID"  where ICUBE = ODS1 from table "RSMONICDP"
    2) Populate above selected fields data in INTERNAL TABLE
    3) Sort INTERNAL TABLE by Time stamp .
    4)
         If (Record Count = ' 0 ' for current date in internal table )
         update records from  ODS1 to ODS2 where ZDATE = "yesterday date"
         else
         update records from ODS1 to ODS2 where ZDATE= "today date"
         endif.
    Make sure this is full update not delta update from ODS1 to ODS2
    I am sorry, I m not good in Coding but I am sure if  u use this logic,You can meet your requirement.
    I hope you can understand my logic. Let me know if you have any questions,
    Anesh B .

  • Previous days data based on passing parameter and date

    Hi,
    i have one rek..that requirement to to show the previous days data based on the number passing to the parameter parameter.
    lets suppose if user enters the date '25 Mar 2012 in one dashboard prompt and in another prompt user enters the no.of days(Ex: 5).then report should display the last 5 days data i.e 25 mar 2012,24 mar 2012,23 mar 2012,22 mar 2012,21 mar 2012.
    can anybody tell me how can i achieve this..
    Thanks in advance...

    user12255470 wrote:
    Hi,
    i have one rek..that requirement to to show the previous days data based on the number passing to the parameter parameter.
    lets suppose if user enters the date '25 Mar 2012 in one dashboard prompt and in another prompt user enters the no.of days(Ex: 5).then report should display the last 5 days data i.e 25 mar 2012,24 mar 2012,23 mar 2012,22 mar 2012,21 mar 2012.
    can anybody tell me how can i achieve this..
    Thanks in advance...Read the article and adapt it to what you are doing. It's very similar...
    http://oraclebizint.wordpress.com/2008/03/11/oracle-bi-ee-101332-rolling-yearmonth-and-date-filters-moving-window-filters/

  • SQL Server - Previous day data retrieval + conditions

    Hi Guys,
    I am retrieving data from a view for a dashboard and I need some help with my query to retrieve yesterday's data where the following conditions meet:
    When 'Monday' retrieve JUST friday's data. When 'Tuesday' retrieve data from Saturday until Monday, When 'other days' JUST retrieve previous day,
    But there is another condition: Exclude 'previous day' data WHERE "DESP_PostedDate..." column is empty. (as this will skew the percentages)
    This is what I have so far:
    SELECT CORD_DocumentCode
    ,OpenDate
    ,datedue
    ,DESP_PostedDate
    ,COUNT(CORD_DocumentCode) AS Order_Count
    ,SUM(CASE WHEN InFullAndOneTime = 2 THEN 1 ELSE 0 END) AS Difot_count
    ,SUM(CASE WHEN InFullAndOneTime = 2 THEN 1 ELSE 0 END) * 1.0 /COUNT(CORD_DocumentCode) AS DIFOT
    FROM DIFOTIS_View
    WHERE (OpenDate >= CASE
    WHEN DATENAME(dw, CONVERT(CHAR(8), GETDATE(), 112)) LIKE 'Monday' THEN CONVERT(CHAR(8), DATEADD(dd, - 2, GETDATE()), 112)
    WHEN DATENAME(dw, CONVERT(CHAR(8), GETDATE(), 112)) LIKE 'Tuesday' THEN CONVERT(CHAR(8), DATEADD(dd, - 3, GETDATE()), 112) ELSE CONVERT(CHAR(8),
    DATEADD(dd, - 1, GETDATE()), 112) END) GETDATE(), 112))
    GROUP BY OpenDate
    ,CORD_DocumentCode
    ,datedue
    ,DESP_PostedDate
    ORDER BY OpenDate
    This will show you last week's date from "Wednesday" and the result is 15.4 % (or 4/26) whereas I would like it to show 80% (or 4 / 5)
    I have tried adding
    ((Datediff(day,Opendate,getdate())=1) and DESP_PostedDate is not null)
    but it shows then ONLY data from the previous day.
    What do you suggest I should do? Please find below Data from friday for your perusal.
    All help is appreciated. Thanks
    Eric
    CORD_DocumentCode OpenDate datedue DESP_PostedDate Order_Count Difot_count DIFOT
    CASW92195 2014-10-19 2014-10-19 2014-10-20 1 1 1.000000000000
    CASW92196 2014-10-19 2014-10-19 2014-10-20 1 1 1.000000000000
    CASW92197 2014-10-19 2014-10-19 2014-10-20 1 1 1.000000000000
    CASW92198 2014-10-19 2014-10-19 2014-10-20 1 1 1.000000000000
    CASW92199 2014-10-19 2014-10-19 2014-10-20 1 1 1.000000000000
    CASW92200 2014-10-19 2014-10-19 NULL 1 0 0.000000000000
    CASW92201 2014-10-20 2014-10-20 2014-10-20 1 1 1.000000000000
    CASW92202 2014-10-20 2014-10-20 2014-10-20 1 1 1.000000000000
    CASW92203 2014-10-20 2014-10-20 2014-10-21 1 1 1.000000000000
    CASW92204 2014-10-20 2014-10-20 2014-10-21 1 1 1.000000000000
    CASW92205 2014-10-20 2014-10-20 2014-10-21 1 1 1.000000000000
    CASW92206 2014-10-20 2014-10-20 2014-10-21 1 1 1.000000000000
    CORD37188 2014-10-20 2014-10-20 NULL 1 0 0.000000000000
    CORD37189 2014-10-20 2014-10-20 2014-10-20 1 0 0.000000000000
    CORD37190 2014-10-20 2014-10-20 2014-10-20 1 0 0.000000000000
    CORD37191 2014-10-20 2014-10-20 2014-10-21 1 0 0.000000000000
    CORD37192 2014-10-20 2014-10-20 2014-10-20 1 0 0.000000000000
    CORD37193 2014-10-20 2014-10-20 2014-10-20 1 0 0.000000000000
    CORD37195 2014-10-20 2014-10-20 2014-10-20 1 0 0.000000000000
    CORD37196 2014-10-20 2014-10-20 2014-10-20 1 0 0.000000000000
    CORD37197 2014-10-20 2014-10-20 2014-10-21 1 0 0.000000000000
    CORD37198 2014-10-20 2014-10-20 2014-10-21 1 0 0.000000000000
    CORD37199 2014-10-20 2014-10-20 2014-10-20 1 0 0.000000000000
    CORD37200 2014-10-20 2014-10-20 NULL 1 0 0.000000000000
    CORD37211 2014-10-20 2014-10-20 2014-10-21 1 1 1.000000000000
    CORD37216 2014-10-20 2014-10-20 2014-10-21 1 1 1.000000000000
    CASW92207 2014-10-21 2014-10-21 2014-10-21 1 1 1.000000000000
    CASW92208 2014-10-21 2014-10-21 2014-10-21 1 1 1.000000000000
    CASW92209 2014-10-21 2014-10-21 2014-10-21 1 1 1.000000000000
    CASW92210 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CASW92211 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CASW92212 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CASW92213 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37218 2014-10-21 2014-10-21 2014-10-21 1 1 1.000000000000
    CORD37220 2014-10-21 2014-10-20 2014-10-21 1 0 0.000000000000
    CORD37221 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37222 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37225 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37227 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37228 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37229 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37230 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37231 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37232 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37233 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37234 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37235 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37236 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37237 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37238 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37239 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    CORD37241 2014-10-21 2014-10-21 NULL 1 0 0.000000000000
    Thanks
    Eric

    Hi Eric,
    Pleas try below code ,Hope this help you
    As per My understanding you were looking for below logic
    If Monday --> Friday only
     Tuesday --> Saturday,sunday, Monday
    Rest Days-->only Preovious Day
    plus additional rule desp_posted date is null then exclude yestreday's data.
    /*Main Query */
    declare @ReportDate datetime
    set @ReportDate='2014-10-22 00:00:00.000'
    select
    OpenDate,cast(datepart(dw,OpenDate) as varchar),DESP_PostedDate
    from base
    where cast(datepart(dw,OpenDate) as varchar)
    in ( SELECT * FROM dbo.CSVToTable(
    case
    when datepart(dw,@ReportDate) =7 then '6'
    when datepart(dw,@ReportDate) =6 then '5'
    when datepart(dw,@ReportDate) =5 then '4'
    when datepart(dw,@ReportDate) =4 then '3'
    when datepart(dw,@ReportDate) =2 then '6'
    when datepart(dw,@ReportDate) =3 and DESP_PostedDate is not null then '7,1,2'
    when datepart(dw,@ReportDate) =3 and DESP_PostedDate is null then '7,1'
    when datepart(dw,@ReportDate) =1 then '7' Else NULL END )) and opendate>=DATEADD(day, -7,@ReportDate)
    /* Table Creation & Sample data */
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE FUNCTION [dbo].[CSVToTable] (@InStr VARCHAR(MAX))
    RETURNS @TempTab TABLE
    (id int not null)
    AS
    BEGIN
    ;-- Ensure input ends with comma
    SET @InStr = REPLACE(@InStr + ',', ',,', ',')
    DECLARE @SP INT
    DECLARE @VALUE VARCHAR(1000)
    WHILE PATINDEX('%,%', @INSTR ) <> 0
    BEGIN
    SELECT @SP = PATINDEX('%,%',@INSTR)
    SELECT @VALUE = LEFT(@INSTR , @SP - 1)
    SELECT @INSTR = STUFF(@INSTR, 1, @SP, '')
    INSERT INTO @TempTab(id) VALUES (@VALUE)
    END
    RETURN
    END
    GO
    /****** Object: Table [dbo].[base] Script Date: 10/28/2014 6:07:17 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[base](
    [CORD_DocumentCode] [varchar](50) NULL,
    [OpenDate] [datetime] NULL,
    [datedue] [datetime] NULL,
    [DESP_PostedDate] [datetime] NULL,
    [Order_Count] [int] NULL,
    [Difot_count] [int] NULL,
    [DIFOT] [numeric](18, 2) NULL
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING ON
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92195', CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92196', CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92197', CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92198', CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92199', CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92200', CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3C900000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92201', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92202', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92203', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92204', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92205', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92206', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37188', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37189', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37190', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37191', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37192', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37193', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37195', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37196', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37197', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37198', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37199', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37200', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37211', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37216', CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92207', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92208', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92209', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92210', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92211', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92212', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CASW92213', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37218', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37220', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CA00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37221', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37222', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37225', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37227', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37228', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37229', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37230', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37231', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37232', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37233', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37234', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37235', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37236', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37237', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37238', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37239', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37241', CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37985', CAST(0x0000A3C800000000 AS DateTime), CAST(0x0000A3C800000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 2, 0, CAST(1.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD379865', CAST(0x0000A3C700000000 AS DateTime), CAST(0x0000A3C700000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 1, CAST(3.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37875', CAST(0x0000A3C600000000 AS DateTime), CAST(0x0000A3C600000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37241', CAST(0x0000A3C500000000 AS DateTime), CAST(0x0000A3C500000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 1, 0, CAST(0.00 AS Numeric(18, 2)))
    GO
    INSERT [dbo].[base] ([CORD_DocumentCode], [OpenDate], [datedue], [DESP_PostedDate], [Order_Count], [Difot_count], [DIFOT]) VALUES (N'CORD37263', CAST(0x0000A3C400000000 AS DateTime), CAST(0x0000A3C500000000 AS DateTime), CAST(0x0000A3CB00000000 AS DateTime), 2, 0, CAST(3.00 AS Numeric(18, 2)))
    GO
    Shiv
    please mark as Answer if helpfull

  • Previous Days Date

    I am looking for a formula that will give me just the date from the current date in Crystal Reports 2008.  I need to produce reports from the previous day for publishing to the users.  So if I am producing reports today "May 5, 2009" and want to select records based on those posted the previous day "May 4, 2009" how would I do that

    I assume you have a posting date field, if so then use this statement in your selection criteria.
    {posting.date} = currentdate - 1
    That should pick up only those records that were posted the previous day, if you run the report today and so on...

  • Alert on Today's Data Compared with Previous Day Data

    Hi All,
    I've a report with multiple tabs having data like,
    Tab:1                                   Tab:2                                 Tab:3                          Tab:4
    Franchise: ABC                   Franchise                          Franchise                    Same as Tab:3
    Start Date:                           Start Date                          Month
    Operator: XYZ                     Operator                            Operator
    Incoming Node:N01            Outgoing Node                  Incoming Node
    Incoming Path:P01             Outgoing Path                    Incoming Path
    Incoming Count:2                Outgoing Count                 Incoming Count
    Incoming Mins: 10.63          Outgoing Mins                   Incoming Mins
    My requirement here is, I've want an alert on Percentage of Mins comparing its data with the previous day(Month for Tab 3 & 4) mins data. For now I've done this by creating a variable(with Relative Value Function) that stores the previous day or month's mins and stored the difference of these two data into another variable as Variation. I've put a percentage on the Variation variable and put a alert on it. It went well till here but, my requirement also has graphical alert on percentage. I tried adding the Variation variable and percentage and all available measures. But an error showed up with every try saying "Error in dataset values :#COMPUTATION"
    Is there any other to do this report?
    Note: I'm using WebI Rich Client v4.1 SP1

    I tried using Franchise(Dim) and with that i've used Incoming Count, Incoming Mins, Variation separately. But nothing worked.

  • ST03 - Previous day data???

    Hi Guru's,
    I have a query on ST03. My Question is when I log onto a server and try to get the ST03 data for the previous day, I do not get the data until 3AM server time. ie if I want the data for 3/12/08, the data does not reflect on the system till 3AM 3/13/08. Why is it I do not get the data of the previous day at 12.10AM on 3/13/08.
    Useful answers will be rewarded.
    Cheers
    Shankam

    Hi Praveen,
    1) SAP standard job SAP_COLLECTOR_FOR_PERFORMANCE must be schedule hourly in each SAP system. The job must always be scheduled in client 000 with user DDIC or with a user with the same authorisation.
    2) If you want to schedule the SAP_COLLECTOR_FOR_PERFORMANCE job daily. Can you check when SAP_COLLECTOR_FOR_PERFORMANCE job has been scheduled. If you can change the schedule time of SAP_COLLECTOR_FOR_PERFORMANCE job, i think it should resolve your problem.
    Kindly refer below sap notes
    *Note 12103 - Contents of the TCOLL table*
    *Note 16083 - Standard jobs, reorganization jobs*
    Cheers
    Kanthi Kiran

  • ST03N, i am not able to see today n previous day data

    Hii All
    In my ST03N, i am not able to see today n last day data, it shows me data upto last two day before data. plz tell me abt where i can check the retention period.
    System Details:
    SAP: ECC 6.0
    DATA BASE: ORACLE 10G
    OS: AIX5.3
    SAP KERNEL:179
    SAP_ABA: SAPKA70015
    SAP_BASIS:SAPKB70015
    ST-PI:2008_1_700
    PI_BASIS:SAPKIPYJ7F
    Already jobs:
    SAP_COLLECTOR_FOR_PERFMONITOR
    SAP_APPLICATION_STAT_COLLECTOR
    SAP_CCMS_MAPPING_SCHEDULER
    SAP_COLLECTOR_FOR_JOBSTATISTIC
    and saposcol running fine.
    Thanks
    Amit Srivastava
    Basis

    Hi
    You can refere this [Link|No system load data available; may help you
    Regards
    Uday

  • Delete previous day data in table

    Hi,
    I want to delete the data in the table with the condition sysdate-1 i.e. i want to delete yesterday's data, please guide me. if i use the below query my data on the first day of month is not getting deleted.
    select datadate from DELETED_RECORD_LOG where datadate=to_char(sysdate,'yyyymmdd')-1

    why the to_char?
    delete from tbl
    where datadate=sysdate-1or when you are also storing the time information (which you are when you use a DATE)
    delete from tbl
    where trunc  (datadate) = trunc (sysdate) -1Edited by: Alex Nuijten on Jun 1, 2009 12:09 PM

  • Previous day data

    i need todo following in the reports:
    1. In the beginning of the report, a summary of the following:
           For the last 5 days, count of "emails(string)"
           (ii) For the last 5 days, the u201CFromu201D addresses and the count of how many emails they had sent to the address each day.
    Can you give idea of how todo in crystal report?

    Hi, 
    If your report is only for the last 5 days you can create a Record Selection Formula like: 
    {table.SENT_DATE} >= Today - 5;
    In the Report Header you can do a Count summary of the e-mails. 
    For the From addresses, you can create a group on the From address.  In the GroupHeader, you can show the e-mail address and a Count summary. 
    Hope this helps,
    Brian

  • To retrieve previous day's data-ods

    Hi friends,
    i got a requirement like we should get the previous days data in to our ods.
    i.e. we are extracting the data daily into our ods from crm (the data related to the daily complaints.i.e. if the user enters the complaint on 25.06.2008, then the officer who is related to that particular department can see the report on 26.06.2008)
    now my requirement is if the user enters the data on 25.06.2008 the should see the corresponding data on 27.06.2008).
    we are extracting the data using function module.
    is there any way to extract the data od day before's.
    please help me
    regards
    sridath
    Edited by: sridath on Jun 27, 2008 11:28 AM

    Hi Sridath,
    Are u talking about the backend side or from the report side of issue..
    If its from the backend side then u cannt get the day before yesterdays data to load.. unless is there is no load has happend yesterday.. If there is no load has happend yesterday .. then u can delete the data before yesterdays load from ur ODS and then take a repeat delta.. in this repeat u can get total 3 days data including the new postings which is there in RSA7.
    Or u can look at the PSA data anyway will load only that particular day load only..
    Let us know the details..
    Thanks
    Assign points if this helps

  • Restore Data from Previous Day

    I have my SQL Database Web Edition hosted on Azure, some stupid user deleted his data, how can I restore from previous day data? 
    TIA
    SV

    Hi vai,
    According to your description, as Mekh’s post, Microsoft Azure SQL Database service has built-in backups to support self-service Point in Time Restore ,Geo-Restore, Point in Time Restore and Geo-Restore are enabled for Basic, Standard, and
    Premium service tiers.
    In a SQL Azure Web database, you need to create a backup, then it will restore and protect your data from application or users errors.
    There is an article about how to setup a backup and restore strategy for a Windows Azure SQL Database. You can review it.
    http://www.mssqltips.com/sqlservertip/3057/windows-azure-sql-database-backup-and-restore-strategy/
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How to get Privious Day data in OBIEE

    Hi experts i need to get preivious day data(Rating Given by Bank to a customer). Because this data (rating) is not an measure so i can't use AGO function.
    So please suggest me how can i Get this without using AGO function.
    Thanks in Advance
    Regards
    Frnds

    Hi..
    yes, need to do as naresh said..
    but in filter you need to assing this..
    Apply filter on your date column
    and click on convert this filter to SQL option..
    here you need to assign the code given by naresh..
    like..
    your datecolumn =*timestampadd(sql_tsi_day,-1,daycolumn)*
    likewise, you get.. but this gives you only previous day data as you asked..
    Thanks & Regards
    Kishore Guggilla

  • Subtracting two fact values of today and Previous day Measures.

    Hi,
    I am having an Requirement in which i need to show the values comong form two fact Tables.
    Consider fact1 will be always having today's date ie(one day record) which is having few Measure Columns.
    Fact2 will be always having previous day date(ie Previous day Record) which is also having some measure Columns.
    Now my Requirement is i need to display fact1.Measure1-Fact2 Measure1 along with today's date.The problem we are facing is that because of the day level granularity we are not geeting previous day record ie(Fact2.Measure1) in the output.I tried union Request because of same granularity problem we are getting null value.
    Kindly help me how to resolve this issue.
    Regards,
    yams

    Can you check this link once you may get some idea if not can you share example with data?
    Re: Second row data -  First row data of other column?

  • Get records from previous day to today

    hi
    i have 1 main table, table A, which has all the data .
    now i have table b which has previous day data and table c which has current data. i need to compare table a(each column)
    to each column in table b and c
    and need to find out rows that has been changed from yesterday to today and send that data.
    table B and table C doesnt have any date which say which date it got changed

    >> I have 1 main table, table A, which has all the data .<<
    What is a “main table”? I never used or heard that term. I am old, so I remember “main” or “master” tape files, however. 
    No table should have all the data in a schema that has more than one relationship in it. Where is the DDL?  
    >> now I have table b which has previous day data and table c which has current data <<
    NO! This design error is called “Attribute splitting” and it usually comes from programmers like you who are using SQL to write 1950's magnetic tape files. Would you have a “Male_Personnel” and a “Female_Personnel”  table or a “Personnel” table? Those
    two absurd tables were split on sex_code, just like you want to split this unknown data on a “<something>_date” attribute. 
    >>  I need to compare table a(each column) to each column in table b and c and need to find out rows that has been changed from yesterday to today and send that data. <<
    No, you need to stop trying to write SQL until you know what you are doing. To track the history of, say, Foobars we need to see time as a continuum and model it as (begin_date, end_date) pairs that define when a foobar had a particular value. Here is the skeleton. 
    CREATE TABLE Foobar_History 
    (foo_id CHAR(9) NOT NULL, 
     start_date DATE NOT NULL, 
     end_date DATE, --null means current 
     CHECK (start_date <= end_date),
     foo_status INTEGER NOT NULL, 
     PRIMARY KEY (foo_id, start_date)); 
    When the end_date is NULL, that state of being is still current. You use a simple query for the status on any particular date;
    SELECT * 
      FROM Foobar
     WHERE @in_cal_date
         BETWEEN start_date
          AND COALESCE (end_date, CURRENT_TIMESTAMP);
    There are more tricks in the DDL to prevent gaps, etc
    CREATE TABLE Events
    (event_id CHAR(10) NOT NULL,
     previous_event_end_date DATE NOT NULL  
     CONSTRAINT Chained_Dates  
      REFERENCES Events (event_end_date), 
     event_start_date DATE NOT NULL, 
     event_end_date DATE UNIQUE, -- null means event in progress
      PRIMARY KEY (event_id, event_start_date), 
     CONSTRAINT Event_Order_Valid 
      CHECK (event_start_date <= event_end_date), 
     CONSTRAINT Chained_Dates 
      CHECK (DATEADD(DAY, 1, previous_event_end_date) = event_start_date)
    -- CHECK (previous_event_end_date + INTERVAL '01' DAYS) = event_start_date)
    -- disable the Chained_Dates constraint
    ALTER TABLE Events NOCHECK CONSTRAINT Chained_Dates;
    GO
    -- insert a starter row
    INSERT INTO Events(event_id, previous_event_end_date, event_start_date, event_end_date)
    VALUES ('Foo Fest', '2010-01-01', '2010-01-02', '2010-01-05');
    GO
    -- enable the constraint in the table
    ALTER TABLE Events CHECK CONSTRAINT Chained_Dates;
    GO
    -- this works
    INSERT INTO Events(event_id, previous_event_end_date, event_start_date, event_end_date)
    VALUES ('Glob Week', '2010-01-05', '2010-01-06', '2010-01-10');
    -- this fails
    INSERT INTO Events(event_id, previous_event_end_date, event_start_date, event_end_date)
    VALUES ('Snoob', '2010-01-09', '2010-01-11', '2010-01-15');  
    --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

Maybe you are looking for