获取所有数据,仅显示返回的相关数据
我的任务是在不重写项目的情况下更改别人的代码。我有一个 sql 语句,可以从客户表中获取所有数据。返回得到:
Inum - which can have many of the same entries.
Istep - Which is unique but bound to above.
Istage - which is unique and bound to above.
它看起来像这样:
10010 - 100 - 999
10010 - 101 - 888
10010 - 102 - 777
10018 - 100 - 999
10018 - 130 - 555
10026 - 300 - 333
我想只获取每个集合的第一个 Inum,以便我得到:
10010 - 100 - 999
10018 - 100 - 999
10026 - 300 - 333
然后我会剥离最后一部分 - Istep 并允许在发生索引更改时将其分配给脚本全部 (VB.NET) 我需要不断获取所有数据,因为它们被打包到页面上的 var 中,并根据其当前内容一遍又一遍地重用。我可能需要用VB来做,不确定。
添加(基于第一个答案): @eaolson - 谢谢您的回复。撇开严重的错别字不谈……我应该更清楚。 Istep 的独特之处在于我们在流程中所处的位置,因为每个项目 (Inum) 一次只能位于一个位置。但它们都在数据库中,并且按照拉动的方式它们都会回来。 Istage也是如此。它对于我们所处的步骤来说是独一无二的,但直到当前点的所有阶段和步骤都会被拉动。我找不到行指南或唯一 ID。他们几乎所有的桌子都是这样做的,很难做出一些改变。我想要的是一个 Inum。因此,调用获取第一个 Inum 10010,然后忽略其余部分,直到获得 chage 10018,然后跳过其余 10018,直到更改 10026,跳过其余部分,直到下一个 10023,等等。我仍然需要所有 * 数据,因为他打包它进入一个 var 并从那里拉到页面下方。我很困惑。我正在考虑将其拉入数据网格(.NET)并将其用于其余的调用。但如果可能的话,我宁愿用 SQL 来完成,因为我知道由于其构建方式,我需要一遍又一遍地执行此操作。谢谢。
I've been tasked to change someone else's code without rewriting the project. I have an sql statement that grabs all data from a customer table. The return gets:
Inum - which can have many of the same entries.
Istep - Which is unique but bound to above.
Istage - which is unique and bound to above.
It looke like this:
10010 - 100 - 999
10010 - 101 - 888
10010 - 102 - 777
10018 - 100 - 999
10018 - 130 - 555
10026 - 300 - 333
I want to just get the first Inum of each set so that I get:
10010 - 100 - 999
10018 - 100 - 999
10026 - 300 - 333
I would then strip off the last part - Istep and allow that to be assigned down the script when an Index change takes place in the all (VB.NET)
I need to keep getting ALL data as it is packaged into a var on the page and is reused based on its current content over and over. I may need to do it in VB, not sure.
Addition (based on first answer):
@eaolson - Thank you for the reply. Gross typos aside...I should have been clearer. The Istep is unique to where we are in the flow in that we can only be one place at a time per item(Inum). But they are all in the db and the way it is pulled they all come back. The same is true for Istage. It is unique to the Step we are in, but all stages and steps up to the current point get pulled. There are no rowguides or unique ID's that I can find. They did most all tables this way and it is tough making some changes. What I want is a single Inum. So the call gets the first Inum 10010, then ignores the rest until it get a chage 10018, then skipps the rest of 10018's until a change 10026, skips the rest until the next 10023, etc. I still neeed ALL * data as he packs it into a var to be pulled from there down the page. I'm stumped. I was thinking to pull it into a datagrid (.NET) and using it for the rest of the calls. But I would rather do it in SQL if possible as I know I will neeed to do this over and over again due to the way this was built. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你说“第一值”时,你的意思是“最小值”吗?表中的行顺序不一定得到保证。
您还说 istep 和 istage 是“唯一的”,但它们在您的示例中具有重复值。我假设 (inum, istep) 是您的主键。
When you say "first value", do you mean "minimum value"? Row order is not necessarily guaranteed in a table.
You also say that istep and istage are "unique" but they have repeating values in your example. I assumed that (inum, istep) is your primary key.