HANA 中的 ORDER BY 与 Excel 中的规则不同
ORDER BY in HANA not the same rule as in Excel
我对 SAP HANA 中的查询结果有排序问题,结果如下:
15-1367
15-1367-BOX
15-1367BO
15-1367BO-AU
15-1367BO-BOX
但是 Excel 中的排序表明:
15-1367
15-1367BO
15-1367BO-AU
15-1367BO-BOX
15-1367-BOX
所以对于 ID 15-1367-BOX,在 Excel 中破折号出现在字母之后,而查询中的排序 returns 破折号出现在字母之前。
如何使用与 Excel 中相同的排序规则在 HANA 中进行排序???
问题出在 excel 上,因为 HANA 对其进行了正确排序。 (无论是 EBCIDIC 还是 ASCII '-' 出现在 'B'.
之前
下面要注意的关键是引用的最后一段!
Excel有这个特质:
When you sort a column that contains alphanumeric characters, the sort
may return unexpected results. Excel sorts the values left to right,
character by character. For example, if a cell contains the text
"A100," Excel places the cell after a cell that contains the entry
"A1" and before a cell that contains the entry "A11."
Excel sorts data in the following order:
0 1 2 3 4 5 6 7 8 9 (space) ! " # $ % & ( ) * , . / : ; ? @ [ \ ] ^ _
` { | } ~ + < = > A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Apostrophes (') and hyphens (-) are ignored, with one exception: If
two text strings are the same except for a hyphen, the text with the
hyphen is sorted last.
来源:microsoft
要解决此问题,您可以创建一个辅助列并将连字符替换为(例如 - 您必须检查您的数据)'&' - 或 select 来自以上将实现 HANA 所做的相同正确结果。然后在排序中包含辅助列。
实施:
在 Excel 列旁边创建一列并使用此公式:=SUBSTITUTE(G5,"-","&")
(选择一个字符非常重要 1)您的数据没有,2)反映在上面的引述中)
我然后 select 两个列,在 HELPER 列上排序!
现在数据的顺序与 HANA 顺序相同。
我对 SAP HANA 中的查询结果有排序问题,结果如下:
15-1367 15-1367-BOX 15-1367BO 15-1367BO-AU 15-1367BO-BOX
但是 Excel 中的排序表明:
15-1367 15-1367BO 15-1367BO-AU 15-1367BO-BOX 15-1367-BOX
所以对于 ID 15-1367-BOX,在 Excel 中破折号出现在字母之后,而查询中的排序 returns 破折号出现在字母之前。 如何使用与 Excel 中相同的排序规则在 HANA 中进行排序???
问题出在 excel 上,因为 HANA 对其进行了正确排序。 (无论是 EBCIDIC 还是 ASCII '-' 出现在 'B'.
之前下面要注意的关键是引用的最后一段!
Excel有这个特质:
When you sort a column that contains alphanumeric characters, the sort may return unexpected results. Excel sorts the values left to right, character by character. For example, if a cell contains the text "A100," Excel places the cell after a cell that contains the entry "A1" and before a cell that contains the entry "A11."
Excel sorts data in the following order:
0 1 2 3 4 5 6 7 8 9 (space) ! " # $ % & ( ) * , . / : ; ? @ [ \ ] ^ _ ` { | } ~ + < = > A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Apostrophes (') and hyphens (-) are ignored, with one exception: If two text strings are the same except for a hyphen, the text with the hyphen is sorted last.
来源:microsoft
要解决此问题,您可以创建一个辅助列并将连字符替换为(例如 - 您必须检查您的数据)'&' - 或 select 来自以上将实现 HANA 所做的相同正确结果。然后在排序中包含辅助列。
实施:
在 Excel 列旁边创建一列并使用此公式:=SUBSTITUTE(G5,"-","&")
(选择一个字符非常重要 1)您的数据没有,2)反映在上面的引述中)
我然后 select 两个列,在 HELPER 列上排序! 现在数据的顺序与 HANA 顺序相同。