Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 My Question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-19 : 05:38:49
kala writes "This is my query.

SELECT BillNo
FROM Bill_Ledger
WHERE (CompanyID = 'BM') AND (LedgerID = '0753')
ORDER BY BillNo

BillNo field is of datatype varchar and size is 20.
I liked to order by BillNo field in Ascending order.Characters are sorted in ascending order but Numbers are not sorted ascendingly.I want the solution please."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-19 : 05:44:33
Posting some sample data with expected result would be helpful

If you have fixed length of data, then this will work

SELECT BillNo
FROM Bill_Ledger
WHERE (CompanyID = 'BM') AND (LedgerID = '0753')
ORDER BY len(BillNo), BillNo


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -