Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009

    Unanswered: get the data along with datediff of two different columns and different rows

    --these are the columns of table1

    id primary key int not null, --identity column
    profile_id int not null,
    ass_name varchar(100),
    start_date datetime,
    end_date datetime

    -- i have a data like these
    -- table1
    id profile_id ass_name start_date end_date
    1 11 ass1 sdate1 edate1
    2 12 ass2 sdate2 edate2
    3 11 ass3 sdate3 edate3
    4 11 ass4 sdate4 edate4
    5 13 ass5 sdate5 edate5

    i want the values ass1, sdate1, edate1, difference between edate1 and sdate2 using profile id

    select ass_name,start_date,end_date,datediff(day,end_date ,start_date) as duration from table1
    where profile_id=11 order by start_date asc

    can any one help me..
    thanks in advance

  2. #2
    Join Date
    Feb 2004
    One Flump in One Place

    In your data your ass ids have no gaps - is this always true?
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts