Don't really know what could be the best title regards my problem. I don't even know if this could be possible. I will take every chance I have.
Let's go with my problem. i have @dateStart and @dateEnd then I have 2 columns for date. let's name it for example dateCol1 and dateCol2 Is it possible to create a condition on
Select * From table Where
case 1 if @dateStart is greater to sample date '1/01/2014' then it would push to the condition
dateCol1 between @dateStart and @dateEnd
else if @dateStart is less than that date i could have a condition of
dateCol2 between @dateStart and @dateEnd
I'm Not really good in SQL, so I would be really thankful if someone could help me here. by the way I'm using microsoft SQL
Select * From table Where case when @dateStart > '1/01/2014' then dateCol1 else dateCol2 end
between @dateStart and @dateEnd
try this solution
Use CASE WHEN... ELSE
CASE
WHEN Boolean_expression THEN.
result_expression [ ...n ]
[ ELSE else_result_expression ]
END
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.