我有一个带有项目,价格和价格日期列的表格。我需要做的是仅过滤掉旧价格,只显示每个项目的最新价格。我正在使用MS Access 2007,并且需要在我编写的某些VBA中引用最新价格,而在我的研究中,我找不到以编程方式访问数据透视表数据以在数据库中其他位置进行客户定价的方法。
表
项目|价格价格日期
答案 0 :(得分:0)
您可以使用相关子查询:
C:\Oracle\Middleware\Oracle_FRHome1\forms
答案 1 :(得分:0)
一个选项使用子查询来查找每个商品的最新价格:
SELECT DISTINCT
accession_no,
object_name,
title,
subject,
authors,
keywords,
resolution_label,
owner_name,
owner_permit,
group_name,
group_permit,
world_permit,
log_entry,
acl_domain,
acl_name,
language_code,
archive_notes,
archive_status,
pier_authors,
pier_author_ids,
compound_nos,
identifiers,
issued_on,
pier_keywords,
organization,
preferred_terms,
protocol_nos,
source_database,
pier_title,
pier_doc_cnt,
created_by,
created_on,
piera_item_type,
piera_barcode,
piera_container_no,
piera_item_description,
piera_location,
piera_microfilm_location,
piera_microfilm_no,
piera_archive_site,
pier_department,
pier_viewurl,
application_name,
file_paths,
alliance_names,
dmr_content_fk,
FROM
pier_record
WHERE
archive_notes in ('51156','51443','51762','51810','18030','50373','52453','51115','51651','50093','18220','18449','50048','51139','52179','52185','52439','52437','51439','51760','51756','51754','51457','51441','51437','51455','51435','51453','5144 5','50726','CCL1','BCL6','ERAP1','HUSH') OR
compound_nos in ('51156','51443','51762','51810','18030','50373','52453','51115','51651','50093','18220','18449','50048','51139','52179','52185','52439','52437','51439','51760','51756','51754','51457','51441','51437','51455','51435','51453','5144 5','50726','CCL1','BCL6','ERAP1','HUSH') OR
identifiers in ('51156','51443','51762','51810','18030','50373','52453','51115','51651','50093','18220','18449','50048','51139','52179','52185','52439','52437','51439','51760','51756','51754','51457','51441','51437','51455','51435','51453','5144 5','50726','CCL1','BCL6','ERAP1','HUSH') OR
pier_keywords in ('51156','51443','51762','51810','18030','50373','52453','51115','51651','50093','18220','18449','50048','51139','52179','52185','52439','52437','51439','51760','51756','51754','51457','51441','51437','51455','51435','51453','5144 5','50726','CCL1','BCL6','ERAP1','HUSH') OR
organization in ('51156','51443','51762','51810','18030','50373','52453','51115','51651','50093','18220','18449','50048','51139','52179','52185','52439','52437','51439','51760','51756','51754','51457','51441','51437','51455','51435','51453','5144 5','50726','CCL1','BCL6','ERAP1','HUSH') OR
protocol_nos in ('51156','51443','51762','51810','18030','50373','52453','51115','51651','50093','18220','18449','50048','51139','52179','52185','52439','52437','51439','51760','51756','51754','51457','51441','51437','51455','51435','51453','5144 5','50726','CCL1','BCL6','ERAP1','HUSH')
ENABLE
(ROW_BASED)
答案 2 :(得分:0)
这比使用MAX()函数更有效:
SELECT Item, Price, PriceDate
FROM customer_pricing t1
WHERE NOT EXITS(
SELECT *
FROM customer_pricing t2
WHERE t1.item = t2.item
AND t1.PriceDate < t2.PriceDate
)
答案 3 :(得分:0)
该解决方案是@dewey提出的,
SELECT t1.item, t1.unit_price1, t1.effect_date, t1.site_ref
FROM dbo_itemprice_mst_all AS t1
WHERE (((t1.site_ref)="MED" Or (t1.site_ref)="CRD") AND ((Exists (SELECT *
FROM dbo_itemprice_mst_all t2
WHERE t1.item = t2.item
AND t1.effect_date < t2.effect_date
))=False))
ORDER BY t1.item;