如何使用MS ACCESS QUERY消除重复值

时间:2016-05-26 03:54:07

标签: c# mysql database access

SELECT [Household Info].[Household Head], [Household Info].Gender, [Household Info].[Household Members], Count(IIf([Household Members.Gender]="Male",0)) AS [Total Male], Count(IIf([Household Members.Gender]="Female",0)) AS [Total Female], Count(IIf([Household Members.Gender]="M","Male","Female")) AS [Total Gender], [Household Data].[Area of Homelot (ha)], [Household Data].[Area of Farmlot (ha)], [Household Data].[Area of Homelot (ha)]+[Area of Farmlot (ha)] AS [Total Area Occupied], [Household Data].[Date of Occupancy] 
FROM [Household Data], [Household Info] INNER JOIN 
[Household Members] ON [Household Info].HID = [Household Members].HID 
GROUP BY [Household Info].[Household Head], [Household Info].Gender, [Household Info].[Household Members], [Household Data].[Area of Homelot (ha)], [Household Data].[Area of Farmlot (ha)], [Household Data].[Area of Homelot (ha)]+[Area of Farmlot (ha)], [Household Data].[Date of Occupancy];

这是MS ACCESS

中查询的输出

输出   enter image description here

我想消除这两个重复的值,因为它应该只有1个Grace Poe,1个PPeter Caapegsan和1个Rodrigo Duterte。

所以是的,它应该只显示3个数据,但我不知道它为什么重复。

1 个答案:

答案 0 :(得分:0)

尝试使用主键。比如把它(例如)放到列reference_numb(ex 1 gracepoe 2 Ppeter Caapegsan 3 Rodrigo duterte)你的reference_numb是数字(基于我的前任)和主键。名称可能是您的列full_Name,因此您无法插入具有相同参考编号的数据