0
我正在编写一个脚本来从两个不同的表中抽取Group By
和MAX(CreatedOnDate),但只返回table1的MAX(CreatedOnDate)大于表2的MAX(CreatedOnDate)的位置。交叉分组和最大日期脚本
例如;
select MasterId, max(createdon) --Master id + latest product generated date
from product
group by MasterId
select contactId, max(createdon) --Contact id + latest edit date for that contact
from contactEdit
group by contactId
from contactEdit ce
join contactmaster cm
on ce.contactId = cm.contactid
join product p
on p.MasterId = cm.MasterId
在这两个表之间有一个contactMaster表,其联接也在上面。我想查找自从创建与该联系人有关的上一个产品以来进行编辑的所有联系人的列表。
有点像;
where max(ce.createdon) > max(p.createdon)