我有一个包含两列的表,并希望根据第 2 列的条件语句过滤第 1 列中的所有唯一值。
我有一个表tblSchoolID
,其中包含 a 列SUID
和Contact_Type
.
SUID
列具有需要根据Contact_Type
的值删除的重复项。Contact_Type
列的条件语句为 1.0 > 2.0 > 4.0 > every other number
。(见下面的示例(
我是MS Access的新手,很难学习如何实现条件语句。
# What I have
SUID Contact_Type
15565966 2.0
15565966 0.0
14737063 4.0
14737063 1.0
14737063 0.0
14737063 2.0
14737063 0.0
16737094 0.0
16737094 0.0
16737094 4.0
# What I need
SUID Contact_Type
15565966 2.0
14737063 1.0
16737094 4.0
我正在使用 Microsoft Access 2013。
group by suid
和一个小技巧来获得最低contact_type
:
select
suid,
min(iif(contact_type = '0.0', '5.0', contact_type )) as con_type
from tblSchoolID
group by suid
结果:
suid con_type
14737063 1.0
15565966 2.0
16737094 4.0
假设concatype是一个字符串,并且总是格式化为x.y您可以尝试对 SUID 对不同于"0.0"的所有值使用 min(contact_type( 组
select SUID, min(contact_type) contact_type
from my_table
where contact_type <> '0.0'
group by SUID