Please Help. I need to write a query that will return the record FS number that is used the most often for the TIN. So for example I have the following table
tblOAFeeScheduleListing
T30 Tin Nbr T46 Fs Nbr CountOfT46 Fs Nbr myID
328328038 9053 1 15
382617193 1201 1 16
382617193 2000 79 17
382617193 207 78 18
382617193 2550 178 19
382617193 265 88 20
And I need the following result
tblOAFeeScheduleListing
T30 Tin Nbr T46 Fs Nbr CountOfT46 Fs Nbr myID
328328038 9053 1 15
382617193 2550 178 19
I have tried using the max function, but just get the results of the top table. I have also tried modeling my query after ones I have found in the forum using and only receive one record back. Below is my SQL
SELECT tblOAFeeScheduleListing.[T30 Tin Nbr], tblOAFeeScheduleListing.[T46 Fs Nbr], tblOAFeeScheduleListing.[CountOfT46 Fs Nbr]
FROM tblOAFeeScheduleListing INNER JOIN tblOAFeeScheduleListing AS tblOAFeeScheduleListing_1 ON tblOAFeeScheduleListing.myID = tblOAFeeScheduleListing_1.myID
where tblOAFeeScheduleListing.[CountOfT46 Fs Nbr] = (SELECT MAX([CountofT46 Fs Nbr]) FROM [tblOAFeeScheduleListing]);
Any help is appreciated….
tblOAFeeScheduleListing
T30 Tin Nbr T46 Fs Nbr CountOfT46 Fs Nbr myID
328328038 9053 1 15
382617193 1201 1 16
382617193 2000 79 17
382617193 207 78 18
382617193 2550 178 19
382617193 265 88 20
And I need the following result
tblOAFeeScheduleListing
T30 Tin Nbr T46 Fs Nbr CountOfT46 Fs Nbr myID
328328038 9053 1 15
382617193 2550 178 19
I have tried using the max function, but just get the results of the top table. I have also tried modeling my query after ones I have found in the forum using and only receive one record back. Below is my SQL
SELECT tblOAFeeScheduleListing.[T30 Tin Nbr], tblOAFeeScheduleListing.[T46 Fs Nbr], tblOAFeeScheduleListing.[CountOfT46 Fs Nbr]
FROM tblOAFeeScheduleListing INNER JOIN tblOAFeeScheduleListing AS tblOAFeeScheduleListing_1 ON tblOAFeeScheduleListing.myID = tblOAFeeScheduleListing_1.myID
where tblOAFeeScheduleListing.[CountOfT46 Fs Nbr] = (SELECT MAX([CountofT46 Fs Nbr]) FROM [tblOAFeeScheduleListing]);
Any help is appreciated….