我想在SQL中获得类似下面的内容
if (current time in between 5AM to 3PM )
then print "firsshift"
else (current time in between 5AM to 3PM)
then print "second shift"
答案 0 :(得分:2)
DECLARE @CurrentTime AS TIME
SET @CurrentTime = GETDATE()
SELECT @CurrentTime AS CurrentTime,
CASE
WHEN @CurrentTime BETWEEN '5:00:00' AND '15:00:00' THEN
'First Shift'
ELSE
'Second Shift'
END AS WhichShift