I have to keep end date for the previous record before creatign new record

  • I have to keep end date for the previous record before creatign new record?

    I have multiple records storing in one table.every time before creating new record end the previous record with end date.

    What query can i write for that?

    I have to write in a case statment.

    Thanks.

  • Why does it have to be a case statement?

    Can you provide the table definitions and some sample data?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Declare @workflow_activity_type_identifier int,

    @workflow_identifier

    select @workflow_activity_type_identifier=workflow_activity_type_identifier from workflow_activity

    where workflow_activity_identifier = @workflow_activity_identifier

    select @sequence_number = case @workflow_activity_type_identifier

    when 197 then 1

    when 203 then 1

    when 200 then(select count(*) from workflow_activity where workflow_activity_type_identifier = 200

    and workflow_identifier = @workflow_identifier)

    when 201 then(select count(*) from workflow_activity where workflow_activity_type_identifier = 201

    and workflow_identifier = @workflow_identifier)

    else 0

    end

    In the above code on workflow_activity_type_identifier = 200 or 201 on this identifier multiple records are created i have to keep end date for the previous record.

    these workflow_activity_type_identifier having workflow_activity_code's are SIFW04 and SIFW05.using these code i have to keep end date for the previous record when ever creating new record on the same workflow_activity_type_identifier's(200,201)

    Thanks

  • Why not just declare a datetime variable and grab the value when you get the activity type identifier? Will that not do what you need?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Canu send a query for that as an example?

  • Declare @workflow_activity_type_identifier int,

    @workflow_identifier,

    @Date datetime

    select @workflow_activity_type_identifier=workflow_activity_type_identifier from workflow_activity,

    @Date = End_Date

    where workflow_activity_identifier = @workflow_activity_identifier

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply