I've been trying to do this for a long time, and i'm at the point where my head may explode.. Please take caution when reviewing my code as it may cause more confusion than it is intended to.
I've got a table named Test that includes multiple fields:
[Management]|[Group]|[Employee]|[Amount]|[Variance]|[DateTime]
I'm trying to pull 25% of the records for each of the Managers listed in the "Management " field, but not just any 25%..
This set of code was my sad attempt to pull 25% of each of the employee's records not including any records that contain "0" in the "Amount" field.
Then my thought was that I would use a UNION ALL to tie in all of the records that have "0" in the "Amount" field. I didnt have any success with this thought and even if i did, it wouldnt have given me the target 25%.
::Edit:: I have Access 2000.
Any suggestions? Thank you in advance for any help you may be able to offer!
I've got a table named Test that includes multiple fields:
[Management]|[Group]|[Employee]|[Amount]|[Variance]|[DateTime]
I'm trying to pull 25% of the records for each of the Managers listed in the "Management " field, but not just any 25%..
- I'm needing to ensure that I dont exclude any given employee in the "Employee" field. I need a sample of all employees.
- I want the 25% to be based off of the TOP of "Variance" in DESC order.
- I also need to include all records that have "0" in the "Amount" field.
This set of code was my sad attempt to pull 25% of each of the employee's records not including any records that contain "0" in the "Amount" field.
Code:
SELECT Managment, Employee, Max(DateTime) AS MAXDateTime, Amount, Variance FROM Test GROUP BY Employee, Variance, Management HAVING Amount IN (SELECT TOP 25 PERCENT Variance FROM Test AS DUPE WHERE Test.Employee=DUPE.Employee AND Amount<>0 ORDER BY DUPE.Variance DESC, DUPE.DateTime DESC) ORDER BY Employee, Variance DESC
::Edit:: I have Access 2000.
Any suggestions? Thank you in advance for any help you may be able to offer!
Comment