I have two queries. The first manipulates the data and sorts it. The second query is based on the first and groups one field and displays another. I'm using the First() function on the field that is displayed, but it is pulling the second one (also the last one, as there are only two in that group). Originally, I thought I just needed to sort it on that field in order to make sure that the order was correct, but that didn't fix it. I originally had several fields, but I have eliminated all but the one and it still has the problem.
Here is the SQL for the trimmed down query:
And here is the SQL for the whole query:
As you can see in the whole query, there are a few fields on which I'm using the First() function and they are all doing the same thing. I'm not sure what is wrong.
Here is the SQL for the trimmed down query:
Code:
SELECT First(qryFixedDates.pol_idx) AS Firstpol_idx FROM qryFixedDates GROUP BY qryFixedDates.Policy ORDER BY First(qryFixedDates.pol_idx);
Code:
SELECT qryFixedDates.Policy , First(qryFixedDates.pol_idx) AS Firstpol_idx , First(qryFixedDates.brch) AS Firstbrch , Max(qryFixedDates.effective) AS Maxeffective , Max(qryFixedDates.expired) AS Maxexpired , Min(qryFixedDates.datewritten) AS Mindatewritten , Sum(qryFixedDates.prem) AS TotalPrem , First(qryFixedDates.prem) AS FirstPrem , First(qryFixedDates.bco) AS FirstOfbco , Count(qryFixedDates.Pol_idx) AS Num FROM qryFixedDates GROUP BY qryFixedDates.Policy HAVING (((Max(qryFixedDates.expired))>#12/1/2015#)) ORDER BY First(qryFixedDates.pol_idx);
Comment