动态获取数字列的最大和最小允许值?
假设有一个名为 money
的列,该列为 NOT NULL
并且其类型为 NUMBER(x,y) 。对此列没有任何约束。
我想根据这个顺序对 money
列进行排序,+ve > -ve> 0 ,所以我的计划是将 0 值解码为 order by 子句中 Money 列可以容纳的最小允许值,例如 select * from tableXXX order by Dece(money, 0 , allowedMnimumValueForMoneyColumn , Money) desc< /代码> .我只是想知道是否可以动态获取货币列的最小允许值。
如何获得列的最大和最小允许值? oracle有隐式变量来做这件事吗?
Suppose a column called money
, which is NOT NULL
and its type is NUMBER(x,y) .There is no constraint on this column.
I want to sort this money
column according to this sequence , +ve > -ve > 0 , so my plan is to decode the 0 value to the minimum allowable value that the money column can hold in the order by clause, like select * from tableXXX order by decode(money, 0 , allowableMnimumValueForMoneyColumn , money) desc
. I just wonder if it is possible to get the minimum allowable value for the money column dynamically.
How can I get the maximum and minimum allowable value for a column ? Does oracle has the implicit variables to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您似乎希望
money
= 0 的记录出现在最后。如果是这种情况,您将采用这样的顺序条款:
通过一个工作示例,这将
导致
It seems that you want the records whose value for
money
= 0 appear last.If this is the case you would go by such an order clause:
With a working example, that would be
resulting in
您不必知道最小值。您可以将 NULL 视为最小值:
You don't have to know the minimum value. You can treat NULL as the minimum value:
您需要在列上创建检查约束:
You need to create a check constraint on the column: