如何按字母顺序排序记录,但只排除一个记录 [英] How To Sort Records Alphabetically BUT Exclude Just One Record

查看:74
本文介绍了如何按字母顺序排序记录,但只排除一个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查询ASP Classic以应用于Access数据库。


1.想象一下,我们有一个名为的表格。国家/地区

2.想象一下,我们在国家/地区中有一个名称为" CityMajor"

3.想象一下,我们希望查询对此列中的项目进行排序,但有一个例外:其中一条记录应位于其他记录之上而其他记录按字母顺序排序

4.一个例子可以澄清这一点。例如,我们的列表中包含以下主要城市的列表(按字母顺序排序)


巴黎
伦敦

德黑兰

罗马

纽约

柏林

东京


5.现在我们希望按照字母顺序返回此列表,但纽约除外 on其他城市的顶部。但其他项目应按字母顺序排列:

纽约

Berline

伦敦

巴黎

罗马

德黑兰

东京


如何完成此查询访问数据库的ASP Classic?


提前感谢您提供这方面的任何帮助。

I would like to have a query for ASP Classic to be applied on an Access database.

1. Imagine that we have a table with the name of "Country".
2. Imagine that we have a column in "Country" that has this name: "CityMajor"
3. Imagine that we wish to have a query sort the items in this column, but with one exception: One of the records should stand on top of the other records while other records are sorted alphabetically.
4. An example could clarify this point. For example, we have the list of the following Major Cities in our list (Unsorted Alphabetically):

Paris
London
Tehran
Rome
New York
Berlin
Tokyo

5. Now we wish to have this list returned and sorted alphabetically, but with the exception that "New York" stands on top of the other cities. But the other items should be in alphabetical order:

New York
Berline
London
Paris
Rome
Tehran
Tokyo

How can I accomplish this query in ASP Classic for an Access Database?

Thank you in advance for any help in this regard.

推荐答案

  1. 如果您希望简单地生成一个List,则在列表顶部将所需城市的名称传递给以下函数。所有其他城市将按字母顺序排列。为了简洁和简洁起见,代码不包括错误检查,主要假设[City Major]字段是必需的(不能为NULL),并且只对传递给函数的字符串执行最小的验证。
  1. If you wish to simply generate a List, then pass to the following Function the Name of the City you want at the Top of the List. All other Cities will follow alphabetically. For the sake of brevity and simplicity, the Code does not include Error Checking, makes the major assumption that the [City Major] Field is REQUIRED (cannot be NULL), and only minimal Validation is performed as regards the String passed to the Function.
展开 | 选择 | Wrap | 行号


感谢您提供干净的代码。

因为我不是那么专业就像你一样,我发现你的代码相当困难。我将你的代码粘贴到一个新的VB表单中,但它停在这一行:

Thank you for your clean code.
Since I''m not as professional as you, I find your code rather difficult. I pasted your code in a New VB Form, but it stopped on this line:

展开 | 选择 | Wrap | 行号


DCount是Access中包含的函数的一部分,因此它应该正常工作。您实际运行的是不在Access VBA环境中的代码吗?
DCount is part of the function contained in Access, so it should be working. Are you actually running the code that is not in the Access VBA environment?


这篇关于如何按字母顺序排序记录,但只排除一个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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