我有這樣SQL排序不能正常工作
CREATE TABLE [dbo].[tbl_LandRigs](
[ID] [int] IDENTITY(700000,1) NOT NULL,
[Company] [nvarchar](500) NULL,
[Rig] [nvarchar](500) NULL,
[RigType] [nvarchar](200) NULL,
[DrawWorks] [nvarchar](500) NULL,
[TopDrive] [nvarchar](200) NULL,
[RotaryTable] [nvarchar](500) NULL,
[MudPump] [nvarchar](500) NULL,
[MaxDD] [nvarchar](50) NULL,
[Operator] [nvarchar](500) NULL,
[Country] [nvarchar](200) NULL,
[Location] [nvarchar](500) NULL,
[OPStatus] [nvarchar](200) NULL,
[CreatedDate] [datetime] NULL,
[CreatedByID] [int] NULL,
[CreatedByName] [nvarchar](50) NULL,
CONSTRAINT [PK_tbl_LandRigs] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
一個表,我試圖讓降序排列
SELECT distinct "MaxDD" FROM [tbl_LandRigs] ORDER BY "MaxDD" Desc
從MaxDD列數據但這按照以下順序 返回數據 根據我的計算,4000必須是其他人的第一個值。但這個結果使我驚訝。能幫我解決這個問題嗎?
你正在將它們存儲爲文本('nvarchar'),爲什麼你得到[詞法順序](http://en.wikipedia.org/wiki/Lexicographical_order) –