[AccessD] Query question, choose TOP from Group?

Asger Blond ab-mi at post3.tele.dk
Thu Jul 8 09:43:39 CDT 2010


Larry,

Don't see why you need to sort descending by PriceDate. Won't something like this do (since a max-aggregation on PriceDate should give you the most recent record)?

SELECT Company, MaterialName, Max(PriceDate) AS MaxPriceDate
FROM MyTable
GROUP BY Company, MaterialName

Asger

-----Oprindelig meddelelse-----
Fra: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] På vegne af Lawrence Mrazek
Sendt: 8. juli 2010 15:56
Til: 'Access Developers discussion and problem solving'
Emne: [AccessD] Query question, choose TOP from Group?

Hi folks:

I'd like to bind a listbox to use a query that returns the top record for
each item in a group, where the group is sorted by date descending.

Basically, I have:

Company
MaterialName
PriceDate

Basically, would like to group by Company, MaterialName, and sort desc by
PriceDate ... I only want to see the most recent record for each
Company/Material Name combination. Each Company / Material combo could have
a different date, so I can't limit it that way. 

Can I do this with a query? Another method? 

Thanks in advance!

Larry Mrazek
ph. 314-496-1645
lmrazek at lcm-res.com
http://www.lcm-res.com


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list