I am having trouble with the CASE statement in this procedure:
DELIMITER //
CREATE PROCEDURE getRowsByHourHalfday(xhour smallint)
BEGIN
SET @twelveless = xhour - 12;
SELECT CASE
WHEN (xhour, > 11) THEN SET @realhour = ( xhour - 12);
ELSE SET @realhour = xhour;
END CASE;
SET @first = @realhour * 60;
SET @next = @first + 59;
SELECT * FROM mydb.halfday WHERE minutepart BETWEEN @first AND @next;
END //
DELIMITER ;
This is the pseudo-code for what I am trying:
if hour > 11 then
set newhour = hour - 12;
set first = newhour * 60;
else
set first = hour * 60;
endif
select * from halfday where minutepart between first and (first + 60);
Instead of your
SELECT CASEstatement, through toEND CASE, you should have the following: