SELECT DATEDIFF(day,(SELECT creation_date
FROM time_info
WHERE is_on = 'yes'
LIMIT 0,1),
(SELECT creation_date
FROM time_info
WHERE is_on = 'no'
LIMIT 0,1)
FROM time_info;
我想计算日期差异,但事情不是这样工作的。还有另一种方法可以做到这一点吗?
SELECT DATEDIFF(day,(SELECT creation_date
FROM time_info
WHERE is_on = 'yes'
LIMIT 0,1),
(SELECT creation_date
FROM time_info
WHERE is_on = 'no'
LIMIT 0,1)
FROM time_info;
我想计算日期差异,但事情不是这样工作的。还有另一种方法可以做到这一点吗?
您的大括号 '(',')' 在 SELECT 语句中不平衡。
尝试这个
SELECT DATEDIFF(t1.creation_date,t2.creation_date )
FROM time_info t1
INNER JOIN time_info t2 ON t1.your_id_column = t2.your_id_column
WHERE t1.is_on = 'yes' AND t2.is_on = 'no';
尝试这个
set @date1:=(SELECT creation_date
FROM time_info
WHERE is_on = 'yes'
LIMIT 0,1);
set @date2:= (SELECT creation_date
FROM time_info
WHERE is_on = 'no'
LIMIT 0,1);
select datediff(@date1,@date2);
您需要提供更多信息以了解您要执行的操作