looking for some solutions? You are welcome.

SOLVED: CASE WHEN with specific condition and range condition


I have researched here quiet a bit but i couldn't find the solution i was looking for.

I am trying to write a query to return values for a range of accounts and some specific accounts, the code i have written so far is below


        When right(m.account,9) = '1110.0130' then 'A'
        when right(m.account,9) = '1110.0131' then 'B'
        When right(m.account,9) = '1110.0132' then 'C'
        when right(m.account,9) between '3000.0000' and '3999.9999' then 'D' 
    ELSE '' END AS [Type], Left(M.Account, 4) as Entity, m.activity
FROM Test 

 T.Accounting_Date between '02/01/2019' and '02/28/19' and (Left(M.Account,4) IN (@Entity) OR '' IN (@Entity)) and 
    (Right(M.Account,9) IN ('1110.0130','1110.0131','1110.0132') or substring(T.account,9,4) Between '3000' and '3999')

The problem i have is that how do i put a condition after the where clause to only pull a range of accounts i.e. 3000 - 4000 and also some specific ones as already present in the statement.


Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: