MS Access 2003 - 列表框的字符串值不按字母顺序排序

发布于 2024-08-27 03:23:33 字数 299 浏览 5 评论 0原文

这是一个愚蠢的问题。假设我有一个生成列表框的查询,它会生成三个商店的值

Store A     18
Store B     32
Store C     54

现在,如果我在 sql 语句中 ORDER BY,它唯一要做的就是按字母顺序降序或升序,但我想要一定的顺序(只是因为它们)想要一个特定的订单).....所以有没有办法让我在 SQL 中添加一些东西来得到,即

Store B
Store C
Store A

基本上逐行得到我想要的。谢谢!

Here is a silly question. Lets say I have a query that produces for a list box, and it produces values for three stores

Store A     18
Store B     32
Store C     54

Now if I ORDER BY in the sql statement the only thing it will do is descending or ascending alphabetically but I want a certain order (only because THEY WANT A CERTAIN ORDER) .....so is there a way for me to add something to the SQL to get

Store B
Store C
Store A

i.e. basically row by row what i want. thanks!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久隐师 2024-09-03 03:23:33

将数字字段sequencer添加到包含商店名称的表中。使用sequencer值来确定排序顺序。

SELECT sequencer, store_name FROM YourTable ORDER BY sequencer;

在列表框中,将sequencer列的列宽设置为0。

或者简单地,如 @dscarr 建议,不要在 SELECT 字段列表中包含sequencer,而只需将其包含在 ORDER BY ...

SELECT store_name FROM YourTable ORDER BY sequencer;

Add a numeric field, sequencer, to the table which contains the store names. Use the sequencer values to determine your sort order.

SELECT sequencer, store_name FROM YourTable ORDER BY sequencer;

In the list box, set the column width = 0 for the sequencer column.

Or simply, as @dscarr suggested, don't include sequencer in the SELECT field list, but just include it in the ORDER BY ...

SELECT store_name FROM YourTable ORDER BY sequencer;
脱离于你 2024-09-03 03:23:33

您可以做两件事中的一件。

使用 SWITCH 语句,例如

SELECT Table1.Store, 
       Table1.Val, 
       Switch([Store]="StoreB",1,[Store]="StoreC",2,[Store]="StoreA",3) AS Expr1
FROM Table1
ORDER BY Switch([Store]="StoreB",1,[Store]="StoreC",2,[Store]="StoreA",3);

或使用辅助订单表,它存储商店名称的值以及按值排序。

You can do 1 of 2 things.

Either use a SWITCH stament, something like

SELECT Table1.Store, 
       Table1.Val, 
       Switch([Store]="StoreB",1,[Store]="StoreC",2,[Store]="StoreA",3) AS Expr1
FROM Table1
ORDER BY Switch([Store]="StoreB",1,[Store]="StoreC",2,[Store]="StoreA",3);

Or use a secondary order table, that stores the values of the store names, and an order by value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文