如何按代码显示表格顺序(如 01、02……然后是空列)? [英] How to display a table order by code (like 01, 02… then null columns)?
问题描述
如何按代码显示表格顺序(例如 01、02……然后是空列)?
How to display a table order by code (like 01, 02… then null columns)?
使用 Access 2003 数据库
Using Access 2003 Database
表格
姓名 职称代码 国籍代码
Name Title code Nationality code
Raja 05 03
Ramu 03
Vijay 01 02
John 04 01
Roby 06
Abilash 02 05
等等……,
我想按标题代码、国籍代码显示表格顺序
I want to display a table order by title code, nationality code
在我的国籍代码"字段中,一些列为空,所以我想按标题代码、国籍代码显示表格顺序(例如 01、02……然后是空列)
In my "nationality code" field some of the columns are null, so I want to display a table order by title code, nationality code (like 01, 02… then null columns)
我的查询.
从表中按国籍代码、职称代码选择*
Select * from table order by nationality code, title code
Name Title Nationality
Ramu 03
Roby 06
John 04 01
Vijay 01 02
Raja 05 03
Abilash 02 05
但是在国籍代码中首先出现空值,我想显示像 01、02、03、05 这样的国籍代码,然后是空值
But Null value is coming first in the nationality code, I want to display nationality code like 01, 02, 03, 05 then null values
需要查询帮助.
推荐答案
尝试使用 Nz 函数为 NULL 列提供值,例如 ORDER BY Nz(Nationality,9999999)
Try using the Nz function to provide a value for NULL columns, for example ORDER BY Nz(Nationality,9999999)
请注意,NZ()
只能在 Access 用户界面中使用.对于更中立的方法,您可以尝试在 ORDER BY
子句中使用表达式,例如像
Note the NZ()
will only work within the Access user interface. For a more neutral approach, you could try an expression in the ORDER BY
clause e.g. something like
ORDER BY (LEN(nationality_code) > 0), nationality_code, title_code;
这篇关于如何按代码显示表格顺序(如 01、02……然后是空列)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!