如何将此 SQL 代码转换为 Power Apps?
我有一个 SQL 查询,它显示数据库中某个组的最新记录。为了获取每个组的最新记录,我使用 ID
列,它是一个自动增量列。最高的 ID 号将是最新的记录。
但是,我无法将其转换为 Power Apps 库中的类似代码。
SELECT *
-- from my table
FROM dbo.MyTable
-- where ID is the maximum ID grouped by product_ID
WHERE (ID IN
(SELECT MAX(ID)
FROM dbo.MyTable
GROUP BY product_ID))
and Product_Type = 'Vegetables'
我的尝试,接近了吗?
ForAll(
GroupBy(
SortByColumns(
Filter(MyTable, Product_Type ='Vegetables'),
'product_ID', Ascending, 'ID', Descending),
'product_ID', '_recs'
),
Patch(First(_recs), {product_ID: product_ID})
)
我知道其中一些功能不可“委托”,这可能是问题所在。
I have a SQL query that shows me the latest record for a group in my database. To get the latest record for each group, I use the ID
column, which is an auto-increment column. The highest ID number will be the latest record.
However I cannot convert this to a similar code in Power Apps gallery.
SELECT *
-- from my table
FROM dbo.MyTable
-- where ID is the maximum ID grouped by product_ID
WHERE (ID IN
(SELECT MAX(ID)
FROM dbo.MyTable
GROUP BY product_ID))
and Product_Type = 'Vegetables'
My attempt, is it close?
ForAll(
GroupBy(
SortByColumns(
Filter(MyTable, Product_Type ='Vegetables'),
'product_ID', Ascending, 'ID', Descending),
'product_ID', '_recs'
),
Patch(First(_recs), {product_ID: product_ID})
)
I understand some of these functions are not "delegable" which may be the issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试
这个应该会给你一个所有唯一产品 ID 的数组。
现在,如果您将其放在图库上,您可以向每行添加一个标签,其中显示带有默认文本值的文本标签:
基本上,您获取产品 ID 并查找每行的最大 ID。
有多个选项,这可能需要一些调整,但这将帮助您入门。
Try
This should give you an array of all unique product id's.
Now, if you place it on a gallery, you can add a label to each row where you display a text label with the default text value:
Basically, you take the product ID's and look up the max ID for every row.
There are multiple options, and this might need some tweaking, but this will get you started.