简体   繁体   English

基于uniqueidentifier数据类型列对数据进行排序

[英]Sort Data based on uniqueidentifier data type column

I have table in that there are relation between Parent and Child, in this my ParentID and SID data type is uniqueidentifier , now I want to sort the data based on the it's ParentID. 我有表格,父和子之间有关系,我的ParentID和SID数据类型是uniqueidentifier ,现在我想根据它的ParentID对数据进行排序。 the value in my table is like below: 我的表中的值如下所示:

在此输入图像描述

How can I sort the data of this table based on the ParentID. 如何根据ParentID对此表的数据进行排序。 Any one please help me to archive this. 任何人请帮我归档这个。

You can just use an ORDER BY in your SELECT statement. 您可以在SELECT语句中使用ORDER BY

SELECT SubjectName, ParentID, SubjectID, SID
FROM yourTable
ORDER BY ParentID

It might look like the data isn't sorted but it is, it just sorts different since it is a uniqueidentifier. 它可能看起来像数据没有排序但是它只是排序不同,因为它是一个uniqueidentifier。 Here is some info I found on sorting by GUIDs. 以下是我在按GUID排序时发现的一些信息。

How are GUIDs sorted on SQL server? GUID如何在SQL服务器上排序?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据类型nvarchar转换为uniqueidentifier时出错 - Error converting data type nvarchar to uniqueidentifier SQL中的uniqueidentifier数据类型是否与Access中的自动编号相同? - Is an uniqueidentifier data type in SQL the same as an autonumber in Access? 存储过程错误:“将数据类型nvarchar转换为uniqueidentifier时出错” - Stored procedure error: “Error converting data type nvarchar to uniqueidentifier” SQL Server 2005 UniqueIdentifier和C#数据类型 - SQL Server 2005 UniqueIdentifier and C# Data Type SQL uniqueidentifier 批量数据迁移 - SQL uniqueidentifier bulk data migration MySQL:查询以根据另一列的属性对数据进行排序 - MySQL: query to sort data based on the attribute of another column 如何基于字符串列按降序对数据进行排序? - How to sort a data in desc order based on string column? 如何在SQL Server中根据其中的数据长度对列进行排序 - How to sort a column based on length of data in it in SQL server System.Data.SqlClient.SqlException:不允许从数据类型sql_variant到uniqueidentifier的隐式转换。 - System.Data.SqlClient.SqlException: Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Spark SQL 有条件的 select 列基于列数据类型 - Spark SQL conditionally select column based on column data type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM