This in Access 2003. Pardon me if this is in the wrong spot, but I hoped someone could help.
I have a table with multiple records that have a text represented date field. The date is in a format like: "06/01/2009" I need to select all the fields from the table but only the 6 oldest rows that fall in a range for each group of "DocType, PayTo, ContactName, ContactNumber, DocFooter, PQBName, LetterDate, RetireeFirstNam e, RetireeLastName , Address1, Address2, City, State, ZIP, PQBSSN, EmployerCode" ordered by the DateDue.
Like: Select only records with a date range 01/01/2009 - 12/01/2009, and of those only select the 6 oldest entries for each grouping.
I have monkeyed with this for a bit and am having no luck. I know this is pretty basic, but I just cant seem to make this work. Here is the SQL select I use to get the date from the table now.
To restate the problem: the query is returning too many rows, I ONLY want six rows for each 'group' of distinct values for the seven columns in the order by...
Any help would be very appreciated!
I have a table with multiple records that have a text represented date field. The date is in a format like: "06/01/2009" I need to select all the fields from the table but only the 6 oldest rows that fall in a range for each group of "DocType, PayTo, ContactName, ContactNumber, DocFooter, PQBName, LetterDate, RetireeFirstNam e, RetireeLastName , Address1, Address2, City, State, ZIP, PQBSSN, EmployerCode" ordered by the DateDue.
Like: Select only records with a date range 01/01/2009 - 12/01/2009, and of those only select the 6 oldest entries for each grouping.
I have monkeyed with this for a bit and am having no luck. I know this is pretty basic, but I just cant seem to make this work. Here is the SQL select I use to get the date from the table now.
Code:
SELECT c.DocType , c.PayTo , c.ContactName , c.ContactNumber , c.DocFooter , c.PQBName , c.LetterDate , c.RetireeFirstName , c.RetireeLastName , c.Address1 , c.Address2 , c.City , c.State , c.ZIP , c.PQBSSN , c.EmployerCode , c.AmountDue , c.DateDue , Right(c.[DateDue],4)+Left(c.[DateDue],2)+Mid(c.[DateDue],4,2) AS SORTDATE FROM COUPONS c ORDER BY c.DocType , c.PayTo , c.ContactName , c.ContactNumber , c.DocFooter , c.PQBName , c.LetterDate , Right(c.[DateDue],4)+Left(c.[DateDue],2)+Mid(c.[DateDue],4,2)
Any help would be very appreciated!
Comment