我需要在sql查询中满足where子句条件的列的名称。一旦我有了列名,我就可以将它们用于进一步使用。
代码:
Declare @sdate datetime
Declare @edate datetime
set @sdate='2018-01-01 00:00:00'
set @edate='2018-01-18 23:59:59'
select * from Upload Where
(Select CASE WHEN Step_1 >= @sdate and Step_1 <= @edate THEN 'Step_1') >= @sdate and
(Select CASE WHEN Step_2 >= @sdate and Step_2 <= @edate THEN 'Step_2') >= @sdate
go