gpt4 book ai didi

android - 比较android中的两个Arraylists

转载 作者:行者123 更新时间:2023-11-30 03:32:36 26 4
gpt4 key购买 nike

我有两个名为 arraylist1arraaylist2 的数组列表。

Arraylist1 having fileds instock,Productcode,productname,batchnNo,saledQty,discount and amount, Which stores values from database table named ProductDetails.

Arraylist2 having fields Productcode,minQuantity,maxQuantity,discount,discountType, which stores values from different table named DiscountDetails.

我们需要根据productcode比较arraylist1 和arraylist2。如果产品代码相同,则我需要检查特定产品代码的销售数量来自 arraylist1,我们需要检查它是否会落在 arraylist2 的 minQuantity 和 maxQuantity 之间的范围内。(minQty<=saledQty<=maxQty)

如果它落在 minQuantity 和 maxQuantity 的范围之间,我们需要从 arraylist2 获得那个特定 productCode 的折扣,我们需要在 的位置显示它arraylist1 中该特定代码的 >discount 列。

谁能帮我解决这个问题..在此先感谢。

最佳答案

您是否尝试在数据库 SQL 查询端解决此问题。这可以很容易地放入 sql 查询中。

编辑以回应否决票:

试试这个 SQL 而不是处理两个列表。如果 saledqty 介于 min 和 max 之间,这将为所有产品提供折扣代码,否则提供任何 product.discount。

select p.instock, p.Productcode, p.productname, p.batchnNo, p.saledQty, p.amount, 
isnull(d.discount, p.discount)
from
ProductDetails p
left join
DiscountDetails d on p.Productcode = d.Productcode
and p.saledQty between d.minQuantity and d.maxQuantity

如果只对具有有效折扣的产品感兴趣,则将 left join(外连接)更改为 join(内连接)。

关于android - 比较android中的两个Arraylists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17190026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com