Ordering Help

Asked By thushara nireesh
02-Sep-10 07:15 AM
Earn up to 0 extra points for answering this tough question.

 DA = New SqlDataAdapter("select * from tb_product WHERE SYSTEM='" & cmbSystem.Text & "' and Supplier='" & cmbSupplier.Text & "' and subsystem='" & cmbSubSystem.Text & "' order by SUBSYSTEM asc", con)

The result is as follows
A
B
C
But if it contains numeric also

The result is as follows

32 Ch.
16 Ch.
8 Ch.
A
B
C.

I want the result to be lik this

 8 Ch.
16 Ch.
32 Ch.
A
B
C

 

What can i do for this

  re: Ordering Help

Reena Jain replied to thushara nireesh
02-Sep-10 08:26 AM
hi,

its not possible if datatype is nvarchar, you can use one more field as id and delcare it as int then you can use order by with query

select * from table1 order by id desc

hope this will help

  re: Ordering Help

Sagar P replied to thushara nireesh
02-Sep-10 10:41 AM
Assuming that there will be space between number and character this query will work fine;

select * from tb_product
order by cast(left(SUBSYSTEM, charindex(' ',SUBSYSTEM) -1) as int) ASC

Create New Account