视图的行号 [英] Row Numbers for a View

查看:55
本文介绍了视图的行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了一项我相信的任务,基本上是不可能的,但

我想知道是否有办法实现。


我的老板要我做的是在SQL Server 2000中创建一个视图,

,它不仅会提供某种行号字段,还会提供

将为任意选择和排序产生顺序排序。

因此,如果我的数据是一个表格,其值为A至D且我的用户确实为
选择数据FROM vwTable,结果将是:


行数据

--- ----

1 A

2 B

3 C

4 D


但他们是否从vwTable中选择了SELECT数据订购数据DSC,他们会

获得


行数据

--- ----

1 D

2 C

3 B

4 A


如果做了SELECT数据FROM vwTable WHERE Data IN(' B'',''C''),他们

会得到


行数据

--- --- -

1 B

2 C


在SQL 2005中,当然,这可能相当简单,因为我可以使用

ROW_NUMBER函数。然而,在2000年,似乎完全不可能实现
。然而,我的老板确信必须有某种方式来创建一个计算字段来实现它。


如果我会被诅咒可以找到一种方法。


任何建议都会受到赞赏。

解决方案

< BLOCKQUOTE>>>然而,在2000年,这似乎完全不可能。然而,我的老板是

确信必须有某种方法可以创建一个计算字段来进行
它。




将以下内容粘贴到Google搜索框中:

" dynamic number rows site:support.microsoft.com"


-

Anith


你想在哪里显示数据?

使用前端应用程序这样做


Madhivanan




Anith Sen写道:

2000年,它似乎完全不可能。但是,我的老板确信必须有一些方法可以创建一个计算字段来进行
它。



粘贴以下内容谷歌搜索框:
动态编号行网站:support.microsoft.com




但是,谢谢,虽然这是一个很好的派生行的方法在一个

选择语句中的数字,不幸的是,这不是我老板的要求

我要做的。她想要一个会在

计算字段中产生行数的视图,而不管用户用来选择

数据的顺序。


我宁愿要求用户在他们的

选择中生成行号,wjhich会允许你提供的解决方案。

不幸的是,那不是'这就是我的任务。


I''ve been given a task that I believe is, basically, impossible, but
I''d like to see if there''s a way to do it.

What my boss wants me to do is to create a view, in SQL Server 2000,
that will provide not only a row number field of some sort, but that
will produce sequential ordering for arbitrary selects and orderings.
So, if my data is a table with values from A thru D and my user does
SELECT data FROM vwTable, the result would be:

Row Data
--- ----
1 A
2 B
3 C
4 D

But is they did SELECT data FROM vwTable ORDER BY data DSC, they would
get

Row Data
--- ----
1 D
2 C
3 B
4 A

And if the did SELECT data FROM vwTable WHERE Data IN (''B'', ''C''), they
would get

Row Data
--- ----
1 B
2 C

In SQL 2005, of course, this would be fairly trivial since I could use
the ROW_NUMBER function. In 2000, though, it seems to be utterly
impossible. My boss, however, is convinced that there must be some way
to create a calculated field to do it.

I''ll be cursed if I can figure out a way to do so.

Any suggestions would be appreciated.

解决方案

>> In 2000, though, it seems to be utterly impossible. My boss, however, is

convinced that there must be some way to create a calculated field to do
it.



Paste the following in Google search box:
"dynamically number rows site:support.microsoft.com"

--
Anith


Where do you want to show the data?
Use Front End application to do this

Madhivanan



Anith Sen wrote:

In 2000, though, it seems to be utterly impossible. My boss, however, is
convinced that there must be some way to create a calculated field to do
it.



Paste the following in Google search box:
"dynamically number rows site:support.microsoft.com"



Thanks, however, while that is a good way to derive row numbers in a
select statement, unfortunately it isn''t quite what my boss is asking
me to do. She wants a view that will produce row counts in a
calculated field regardless of the order that the user uses to select
the data.

I would prefer to require the user to generate the row numbers in their
selects, wjhich wouldd allow for the solution you offered.
Unfortunately, that isn''t what I''ve been tasked to do.


这篇关于视图的行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆