排序从特定值开始 [英] Sort Starting at particular value

查看:79
本文介绍了排序从特定值开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从特定值开始对升序列表进行排序。

I'd like to sort an ascending list of times, starting at a particular value.

 

如果在SQL我使用Order By I get:

If in SQL I use Order By I get:

 

9am

10am

上午11点

下午2:30

下午4:45

 

但是说我想从特定值开始,比如上午10点,因为这是公司营业日开始的时候。 在上午9点在网上下达的订单应该显示在列表的底部,因为它距离公司的运营时间从上午10点的b $ b开始最远。

But say I want to start at a specific value, say 10am, because that is when a company's business day begins.  An order placed online at 9am should show up at the bottom of the list, because it is furthest from when the company's operations start at 10am.

 

前:

 

上午10点

上午11点

下午2:30

下午4:45

上午9点

 

 

我可以使用SQL来实现这个结果吗?是否有订单的功能我不知道可以做到这一点,还是我需要使用另一个命令?

Can I use SQL to achieve this result? Is there a feature of Order By I'm not aware of that can do this, or is there another command I would need to use?

推荐答案

如果这些是固定的时间间隔,您可以将它们存储在表格中并为排序顺序添加字段。我经常需要根据重要性排序对事物进行排序,因此我将SortOrder添加到表中并在ORDER BY子句中使用它。
If these are fixed time intervals you can store them in a table and add a field for the sort order. I often have to sort things based on a ranking of importance so I add a SortOrder to the table and use it in the ORDER BY clause.


这篇关于排序从特定值开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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