N
normalit
I am working on a database for a police department tracking the weapons
that officers have qualified with at any time. I have two tables -
tbOFFID & Qualify.
Important fields:
[tbOFFID]:
ID# (primary key, also employee number)
Name
Rank
[Qualify]:
OffID (3 digit numerical employee ID, same as tbOFFID.ID#)
WpnTyp (types of weapons: Primary, Backup, AR15, etc)
Make
Serial
Model
QualDate (qualification date)
The major issue I am facing is getting rid of records with duplicates.
The duplicate field I would like to delete is Serial. If an officer
qualifies every year with a particular weapon, each record will have
the same serial number, but different QualDate values. Makes are also
entered differently in some places: "H&K" vs "H & K", so the records
are not true duplicates.
The goal: to get a list (into a report) of all weapons that an officer
has qualified with, but only list the weapons (by serial) once.
I have tried several methods, and am not able to get the final result.
Here are the two queries I tried last. The first is to get all fields
together in one table, which shows duplicate serials. The second was to
attempt to get rid of the duplicate serials. Both are SQL from Access,
with no added code by me.
SELECT Qualify.OffID, tbOFFID.Rank, tbOFFID.Name, Qualify.Make,
Qualify.Model, Qualify.Serial, Qualify.WpnTyp, Qualify.QualDate
FROM Qualify INNER JOIN tbOFFID ON Qualify.OffID = tbOFFID.[ID#]
WHERE (((Qualify.OfcOwn)=True));
******
SELECT [Q All Qualified Weapons].OffID AS [OffID Field], [Q All
Qualified Weapons].Rank AS [Rank Field], [Q All Qualified
Weapons].Name, [Q All Qualified Weapons].Make AS [Make Field], [Q All
Qualified Weapons].Model AS [Model Field], First([Q All Qualified
Weapons].Serial) AS [Serial Field], Last([Q All Qualified
Weapons].QualDate) AS LastOfQualDate, [Q All Qualified Weapons].WpnTyp
FROM [Q All Qualified Weapons]
GROUP BY [Q All Qualified Weapons].OffID, [Q All Qualified
Weapons].Rank, [Q All Qualified Weapons].Name, [Q All Qualified
Weapons].Make, [Q All Qualified Weapons].Model, [Q All Qualified
Weapons].WpnTyp, [Q All Qualified Weapons].OffID, [Q All Qualified
Weapons].Rank, [Q All Qualified Weapons].Make, [Q All Qualified
Weapons].Model, [Q All Qualified Weapons].Serial, [Q All Qualified
Weapons].OffID
HAVING ((([Q All Qualified Weapons].WpnTyp)="Primary Duty Weapon" Or
([Q All Qualified Weapons].WpnTyp)="Backup" Or ([Q All Qualified
Weapons].WpnTyp)="AR15"));
******
I really appreciate any input.
that officers have qualified with at any time. I have two tables -
tbOFFID & Qualify.
Important fields:
[tbOFFID]:
ID# (primary key, also employee number)
Name
Rank
[Qualify]:
OffID (3 digit numerical employee ID, same as tbOFFID.ID#)
WpnTyp (types of weapons: Primary, Backup, AR15, etc)
Make
Serial
Model
QualDate (qualification date)
The major issue I am facing is getting rid of records with duplicates.
The duplicate field I would like to delete is Serial. If an officer
qualifies every year with a particular weapon, each record will have
the same serial number, but different QualDate values. Makes are also
entered differently in some places: "H&K" vs "H & K", so the records
are not true duplicates.
The goal: to get a list (into a report) of all weapons that an officer
has qualified with, but only list the weapons (by serial) once.
I have tried several methods, and am not able to get the final result.
Here are the two queries I tried last. The first is to get all fields
together in one table, which shows duplicate serials. The second was to
attempt to get rid of the duplicate serials. Both are SQL from Access,
with no added code by me.
SELECT Qualify.OffID, tbOFFID.Rank, tbOFFID.Name, Qualify.Make,
Qualify.Model, Qualify.Serial, Qualify.WpnTyp, Qualify.QualDate
FROM Qualify INNER JOIN tbOFFID ON Qualify.OffID = tbOFFID.[ID#]
WHERE (((Qualify.OfcOwn)=True));
******
SELECT [Q All Qualified Weapons].OffID AS [OffID Field], [Q All
Qualified Weapons].Rank AS [Rank Field], [Q All Qualified
Weapons].Name, [Q All Qualified Weapons].Make AS [Make Field], [Q All
Qualified Weapons].Model AS [Model Field], First([Q All Qualified
Weapons].Serial) AS [Serial Field], Last([Q All Qualified
Weapons].QualDate) AS LastOfQualDate, [Q All Qualified Weapons].WpnTyp
FROM [Q All Qualified Weapons]
GROUP BY [Q All Qualified Weapons].OffID, [Q All Qualified
Weapons].Rank, [Q All Qualified Weapons].Name, [Q All Qualified
Weapons].Make, [Q All Qualified Weapons].Model, [Q All Qualified
Weapons].WpnTyp, [Q All Qualified Weapons].OffID, [Q All Qualified
Weapons].Rank, [Q All Qualified Weapons].Make, [Q All Qualified
Weapons].Model, [Q All Qualified Weapons].Serial, [Q All Qualified
Weapons].OffID
HAVING ((([Q All Qualified Weapons].WpnTyp)="Primary Duty Weapon" Or
([Q All Qualified Weapons].WpnTyp)="Backup" Or ([Q All Qualified
Weapons].WpnTyp)="AR15"));
******
I really appreciate any input.