所以我发现这2篇文章,但他们并没有完全回答我的问题...查找特定的值,并显示来自不同领域的相应值在SQL
Find max value and show corresponding value from different field in SQL server
Find max value and show corresponding value from different field in MS Access
我有一个这样的表...
ID Type Date
1 Initial 1/5/15
1 Periodic 3/5/15
2 Initial 2/5/15
3 Initial 1/10/15
3 Periodic 3/6/15
4
5 Initial 3/8/15
我需要得到所有的“周期”或NULL和相应的日期的ID号码。所以,我想获得查询结果,看起来像这样...
ID Type Date
1 Periodic 3/5/15
3 Periodic 3/6/15
4
我已经试过
select id, type, date1
from Table1 as t
where type in (select type
from Table1 as t2
where ((t2.type) Is Null) or "" or ("periodic"));
但是,这并不工作...从我读过有关NULL你不能比较空值... Why in SQL NULL can't match with NULL?
所以,我想
SELECT id, type, date1
FROM Table1 AS t
WHERE type in (select type
from Table1 as t2
where ((t.Type)<>"Initial"));
但是这不会给我4的ID ...
有什么建议吗?
根据你的用户名,我猜测正确的标签是ms-access。 –