Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008

    Unanswered: Comparing 2 rows

    Hi -

    I'd like to compare the date values in a column between two rows. For instance, my table looks like this:

    Row StartDate EndDate
    1 20070101 20070131
    2 20070201 20070228
    3 20070301 20070131
    4 20070401 20070430

    In this example, the idea is to have the first day of the month as the "startdate" and the last day of the month as the "enddate." However, as you can see, the "Enddate" in Row 3 is wrong. It should be 20070331.

    Which query can I use to compare differing values like these in Sybase SQL? Currently, my table has over 6 million rows and I think there are thousands of errors like the one above.

    I really and truly appreciate your feedback.

    Thanks a million!

  2. #2
    Join Date
    May 2005
    South Africa
    Provided Answers: 1
    select * from MyTable
    where EndDate!=dateadd(dd,-1,dateadd(mm,1,StartDate))

Posting Permissions

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