SQL 没有行具有值的分组依据
SQL Group By where no row has value
编写此查询的最佳方式是什么:
SELECT ID 来自 table
其中 "no row with the ID has a created date > '1/1/2012'"
按 ID 分组
总而言之,我只想查看分组 ID,其中每一行都有一个创建日期 >“1/1/2012”
使用 having
子句并查看最大创建日期:
SELECT ID
FROM table
GROUP BY ID
HAVING MAX(CreatedDate) <= '2012-01-01'
select * from (table where date > '2012-01-01') group by id
编写此查询的最佳方式是什么:
SELECT ID 来自 table 其中 "no row with the ID has a created date > '1/1/2012'" 按 ID 分组
总而言之,我只想查看分组 ID,其中每一行都有一个创建日期 >“1/1/2012”
使用 having
子句并查看最大创建日期:
SELECT ID
FROM table
GROUP BY ID
HAVING MAX(CreatedDate) <= '2012-01-01'
select * from (table where date > '2012-01-01') group by id