how to exclude accounts on TSQL where clause

  • Hello comunity

    i have the following TSQL:

    SELECT conta, docnome,u_subconta, data, mlstamp,

    dinome, adoc, dilno, edeb, ecre

    FROM ml where ((ml.conta not like '243%' or ml.conta not like '22%') and (ml.conta between '21101' and '26901'))

    and

    YEAR(ml.data) = 2007 and (ml.mes >= 1 and ml.mes <=10 or (ml.mes = 1 and (case when ml.dia = 0 then datepart(dd, ml.data) else ml.dia end)

    < 1)) and u_subconta like substring('50002',1,5)

    group by conta,docnome,u_subconta,data,

    dinome, adoc, dilno, edeb, ecre ,mlstamp

    ORDER BY conta, u_subconta,data asc

    My problem is between '21101' and '26901' i have account like '243%' and '22%', i want return my result excluding this accounts on my where clause.

    Note : this account are Strings

    Many thanks

    Luis Santos

  • this:

    FROM ml where ((ml.conta not like '243%' or ml.conta not like '22%') and (ml.conta between '21101' and '26901'))

    should be this:

    FROM ml where ((ml.conta not like '243%' and ml.conta not like '22%') and (ml.conta between '21101' and '26901'))

    ---------------------------------------
    elsasoft.org

Viewing 2 posts - 1 through 1 (of 1 total)

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