如何从一个列中获取一个值,并在SQL中的以下行中使用它的自己的详细信息扩展?

发布于 2025-01-22 15:34:16 字数 986 浏览 1 评论 0原文

我有以下结果设置在从汽车价格表中提取汽车价格的详细信息表之后:

汽车ID价格价格按调整金额调整金额
1234$ 1005678-$ 50
0000$ 650
5678$ 349 $ 349

我如何编写SQL功能具有非零值(在这种情况下,另一辆汽车ID,5678,它影响了1234年价格的价格-50美元),在汽车ID之后立即进行调整金额的行显示了5678的详细信息,例如如下:

调整的汽车ID价格调整金额
价格1234$ 1005678-$ 50
5678$ 349
0000$ 650
5678$ 349

牢记,这些汽车可能会产生多个汽车ID的影响,因此,如果我们有两个汽车ID的价格,接下来的两个汽车ID,接下来的两个汽车ID,接下来的两个汽车ID行会显示出从原始源表中影响原始汽车ID价格的两个汽车ID的详细信息吗?

I have the following result set after pulling the details for car prices from a car prices table:

Car IDPricePrice adjusted byadjustment amount
1234$1005678-$50
0000$650
5678$349

How do I write a SQL function, so that if the price_adjusted_by column has a non-null value (in this case another car ID, 5678, that impacts the price of Car 1234's price by -$50), the row immediately following the Car ID that had an adjustment amount shows the details for 5678, such as the following:

Car IDPricePrice adjusted byadjustment amount
1234$1005678-$50
5678$349
0000$650
5678$349

Keep in mind, these cars may have multiple car ID's impacting their price, so if we had two Car ID's impacting the price, the next two rows would show the details for BOTH of the Car ID's impacting the original car ID's price from the original source table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文