MYSQL ::从表中选择没有最新行的行

时间:2023-01-17 15:42:11

I am struggling selecting rows from my table that haven't been modified with the current year. Here is an example of the query i gave up on:

我正在努力从我的表中选择当前年份尚未修改的行。以下是我放弃的查询示例:

SELECT *  FROM test_cars INNER JOIN
 (SELECT car as c, type as t FROM test_cars 
WHERE YEAR(modified_on)='2016' GROUP BY c,t) as tbl 
ON tbl.c!=car AND tbl.t!=type 
WHERE value !='' 
GROUP BY car,type

1 个解决方案

#1


1  

SELECT car, type 
FROM test_cars
GROUP BY car, type
HAVING sum(YEAR(modified_on) = 2016) = 0

#1


1  

SELECT car, type 
FROM test_cars
GROUP BY car, type
HAVING sum(YEAR(modified_on) = 2016) = 0