SET @x := '2018-06-01';
SELECT CASE WHEN WEEKDAY(@x) = 4
THEN CASE WHEN DAYOFMONTH(@x) < 8
THEN 'FIRST FRIDAY'
ELSE 'SOME OTHER FRIDAY' END
ELSE 'NOT FRIDAY' END x;
+--------------+
| x |
+--------------+
| FIRST FRIDAY |
+--------------+
SET @x := '2018-06-08';
SELECT CASE WHEN WEEKDAY(@x) = 4
THEN CASE WHEN DAYOFMONTH(@x) < 8
THEN 'FIRST FRIDAY'
ELSE 'SOME OTHER FRIDAY' END
ELSE 'NOT FRIDAY' END x;
+-------------------+
| x |
+-------------------+
| SOME OTHER FRIDAY |
+-------------------+
SET @x := '2018-06-07';
SELECT CASE WHEN WEEKDAY(@x) = 4
THEN CASE WHEN DAYOFMONTH(@x) < 8
THEN 'FIRST FRIDAY'
ELSE 'SOME OTHER FRIDAY' END
ELSE 'NOT FRIDAY' END x;
+------------+
| x |
+------------+
| NOT FRIDAY |
+------------+
1条答案
按热度按时间8oomwypt1#