Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

CASE statement within WHERE clause

$
0
0

i have a select statement like this

Here DateColumn is INT (which is in yyyymmdd format)

select x, y , z from table a
where CAST( CAST(DATEColumn AS VARCHAR) AS DATE) between  
    case when a.columnx = '1900-01-01' then CAST( CAST(DATEColumn AS VARCHAR) AS DATE) else c.columnx end
    and c.CustomerShipToRecTrmDt

My case statement is not working??

I have columnx....if columnx in that particular column is 1900-01-01, then i am saying...give it DateColumn (which is int, but i am converting that to Date), else columnx


Thanks



Viewing all articles
Browse latest Browse all 23857

Trending Articles