简体   繁体   English

返回 BAQ 中的最新记录

[英]Return Most Recent Record in a BAQ

I apologize that this has been asked before by many people.很抱歉,之前很多人都问过这个问题。 Unfortunately i have almost no knowledge of SQL and have been unsuccessful in making it work based on the previous questions that have been asked and answered.不幸的是,我对 SQL 几乎一无所知,并且根据之前已提出和回答的问题未能使其工作。

I am tasked with creating a BAQ through Epicor10 and I need it to return 1 entry per part # based on the most recent receipt date.我的任务是通过 Epicor10 创建一个 BAQ,我需要它根据最近的收货日期为每个零件返回 1 个条目。 This is my query这是我的查询

    select 
    [PODetail].[PartNum] as [Part #],
    [Part].[PartDescription] as [Part Description],
    [PODetail].[PUM] as [Supplier UOM],
    [PODetail].[DocUnitCost] as [Unit Price],
    [RcvHead].[ReceiptDate] as [Receipt Date]
from Erp.Part as Part
inner join Erp.PODetail as PODetail on 
    Part.Company = PODetail.Company
    and Part.PartNum = PODetail.PartNum
cross join Erp.RcvHead as RcvHead

My results look like this.我的结果看起来像这样。

Part Num    Description Supplier UOM    Unit Price  Receipt Date
100009      4x4-4/4   10" x 35"  EA     4.77        4/9/2020
100009      4x4-4/4   10" x 35"  EA     4.77        4/9/2020
100009      4x4-4/4   10" x 35"  EA     4.77        4/8/2020
100009      4x4-4/4   10" x 35"  EA     4.60        1/7/2020
100009      4x4-4/4   10" x 35"  EA     4.60        1/7/2020
100010      4x4-4/4   10" x 40"  EA     4.89        1/7/2020
100010      4x4-4/4   10" x 40"  EA     4.89        1/7/2020
100010      4x4-4/4   10" x 40"  EA     4.75        8/19/2019
100010      4x4-4/4   10" x 40"  EA     4.75        8/17/2019

When complete i want the results to be.完成后,我希望结果是。

Part Num    Description Supplier UOM    Unit Price  Receipt Date
100009      4x4-4/4   10" x 35"  EA     4.77        4/9/2020
100010      4x4-4/4   10" x 40"  EA     4.89        1/7/2020

If someone could tell me what to put and where to put it in my code that would be extremely helpful.如果有人能告诉我在我的代码中放置什么以及将其放在哪里,那将非常有帮助。 Again, sorry that this has been asked many times I just don't have enough knowledge to get it to work myself.再次,很抱歉,这个问题被问了很多次,我只是没有足够的知识来让它自己工作。 Thank you.谢谢你。

To get the latest receipt date, you need to look at your Sort Order.要获得最新的收货日期,您需要查看您的排序顺序。 Go to: Go 至:

Query Builder > Display Fields > Sort Order查询生成器 > 显示字段 > 排序顺序

You will want to use Receipt Date and make sure its in descending order.您将需要使用 Receipt Date 并确保其按降序排列。

排序顺序所在的 BAQ 屏幕的图像

Then to make the BAQ return one record, go to the SubQuery Options Tab.然后让 BAQ 返回一条记录 go 到子查询选项选项卡。

Query Builder > SubQuery Options查询生成器 > 子查询选项

You can then specify that the BAQ only returns one row by changing the value in the dropdown called "Result Set Rows" to TOP, then specify below to only return one.然后,您可以通过将名为“Result Set Rows”的下拉列表中的值更改为 TOP 来指定 BAQ 仅返回一行,然后在下面指定仅返回一行。

子查询选项屏幕的图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM