Comparison problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sybot_uk

    #1

    Comparison problems

    Hi there, can any one help me? I am new to DB2 sql, I will be using
    the case statement to make comparisons in the select but I cannot get
    it to work. The query below is an example of the comaprison I am tring
    to do, it is not returning any rows. The column qactdat is a numeric
    field which holds a date in the form yyyymmdd.

    select integer(substr( qactdat,5,2)),
    integer((substr (qactdat,5,2)+1-1))
    from qwfldat
    where integer(substr( qactdat,5,2)) = integer((substr (qactdat,
    5,2)+1-1))

    If I remove the where clause, rows are returned. I cannot work out why
    the comaprison is not evaluating to true, as they should both return
    the same number.

    Hope somone can help, many thanks,

    Toby

  • sybot_uk

    #2
    Re: Comparison problems

    I figured out that this is because the column qactdat has some values
    of 0. This meant that the substr(qactdat, 5,2) was not evaluating
    proply. I do find it strange that this didn't cause an error though or
    just evaluate as false and return the rows that do have values in the
    field.

    Comment

    • Tonkuma

      #3
      Re: Comparison problems

      The column qactdat is a numeric
      field which holds a date in the form yyyymmdd.
      What data type did you specified for qactdat in CREATE TABLE qwfldat?

      Comment

      • Tonkuma

        #4
        Re: Comparison problems

        You must be using DB2 for iSeries.
        Please ignore my previous post. Because, I don't know so much about
        iSeries.

        Comment

        Working...