这是有问题的脚本:
select distinct person, min(pdate) as min_date from db
where ptype like 'A1%'
or (ptype like 'B1%'
and (pdate between '2000-01-01' and '2001-01-01'))
group by person
问题
检索的 min_date 还包括我指定的日期之外的那些。但是,当我取出其中一种 ptype 时,我有:
select distinct person, min(pdate) as min_date from db
where ptype like 'A1%'
and (pdate between '2000-01-01' and '2001-01-01')
group by person
然后这个问题就消失了。为什么引入第二个 ptype 会重新调整我指定的更新之外的实例?
谢谢。