Cx_Oracle - 如何指定具有双重排序输出的查询
Cx_Oracle - How to specify a query with a double ordered output
我正在处理 Cx_Oracle 11g 数据库:我想知道是否有可能在 table 的输出中包含两种不同类型的 order by
。我的意思是,假设这些列是 name
、 timestamp
和 value
并且我需要输出如下所示:
nameA - timestamp1 - value
nameA - timestamp2 - value
nameA - timestamp3 - value
nameB - timestamp1 - value
nameB - timestamp2 - value
nameB - timestamp3 - value
其中主要顺序是 name
,timestamp
是为每个不同的 name
排序的。我该怎么办?
From the Oracle documentation:
You can specify multiple expressions in the order_by_clause. Oracle Database first sorts rows based on their values for the first expression. Rows with the same value for the first expression are then sorted based on their values for the second expression, and so on
所以在你的情况下只是做:
order by name, timestamp
在您的查询中将执行您描述的内容。
我正在处理 Cx_Oracle 11g 数据库:我想知道是否有可能在 table 的输出中包含两种不同类型的 order by
。我的意思是,假设这些列是 name
、 timestamp
和 value
并且我需要输出如下所示:
nameA - timestamp1 - value
nameA - timestamp2 - value
nameA - timestamp3 - value
nameB - timestamp1 - value
nameB - timestamp2 - value
nameB - timestamp3 - value
其中主要顺序是 name
,timestamp
是为每个不同的 name
排序的。我该怎么办?
From the Oracle documentation:
You can specify multiple expressions in the order_by_clause. Oracle Database first sorts rows based on their values for the first expression. Rows with the same value for the first expression are then sorted based on their values for the second expression, and so on
所以在你的情况下只是做:
order by name, timestamp
在您的查询中将执行您描述的内容。