Re: how to order by string data type that is actually numeric?
From: Dejan Sarka (dejan_please_reply_to_newsgroups.sarka_at_avtenta.si)
Date: 08/23/04
- Next message: David Portas: "Re: Primary key spread in two tables"
- Previous message: student: "Primary key spread in two tables"
- In reply to: Bobby: "how to order by string data type that is actually numeric?"
- Next in thread: Bobby: "Re: how to order by string data type that is actually numeric?"
- Reply: Bobby: "Re: how to order by string data type that is actually numeric?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 23 Aug 2004 08:01:48 +0200
Use CAST function:
SELECT *
FROM TestTable
ORDER BY CAST(sortstring AS bigint)
-- Dejan Sarka, SQL Server MVP Associate Mentor Solid Quality Learning More than just Training www.SolidQualityLearning.com "Bobby" <bobby.saputra@epselindo.com> wrote in message news:ueL4z5LiEHA.1652@TK2MSFTNGP09.phx.gbl... > Hi... > I just curios about this. > I have 1 tabel 'tbl1' and 1 column 'col1' as string > > Col1 > 110 > 21 > 2 > > > query --> "select * from tbl1 order by col1" > result: > Col1 > 1 > 10 > 2 > 21 > > Question: Can I order the data as numeric, not as string? How? > > I want to get result > Data > Col1 > 1 > 2 > 10 > 21 > > Thanks > >
- Next message: David Portas: "Re: Primary key spread in two tables"
- Previous message: student: "Primary key spread in two tables"
- In reply to: Bobby: "how to order by string data type that is actually numeric?"
- Next in thread: Bobby: "Re: how to order by string data type that is actually numeric?"
- Reply: Bobby: "Re: how to order by string data type that is actually numeric?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|