Solved

Can i order by JUST the first letter of a string in SQL?

Posted on 2008-06-13
2
219 Views
Last Modified: 2012-06-21
is it possible to order by only the first letter of a string in SQL?  for instance, here is my order by:

ORDER BY Silage_Corn_Hybrids_with_Same_Base_Genetics, dbo.parseInt(Silage_Corn_Relative_Maturity), Silage_Corn_Parent_Hybrid

and i have attached how my data is returning.  

i would like it to just display the 'F' Silage_Corn_Hybrids_with_Same_Base_Genetics first and the the 'T', but really sort by Silage_Corn_Relative_Maturity with the Silage_Corn_Parent_Hybrid family.

Is this possible?


F2F297	F2F297	90

F2F444	F2F444	102

F2F449	F2F444	104

F2F485	F2F485	98

F2F487	F2F485	99

F2F489	F2F485	99

F2F566	F2F566	105

F2F568	F2F566	105

F2F569	F2F566	105

F2F610	F2F610	108

F2F631	F2F631	110

F2F633	F2F631	110

F2F635	F2F631	110

F2F682	F2F682	112

F2F699	F697	113

F2F700	F697	113

F2F721	F2F721	113

F2F723	F2F721	113

F2F725	F2F721	113

F2F739	F2F739	113

F2F797	F2F797	115

F697	F697	112

TMF2H917	TMF2H917	123

TMF2H918	TMF2H917	123

TMF2L412	TMF2L412	92

TMF2L414	TMF2L412	92

TMF2L416	TMF2L412	94

TMF2L418	TMF2L412	94

TMF2L831	TMF2L831	118

TMF2L844	TMF2L844	119

TMF2M696	TMF2M696	110

TMF2N422	TMF2N422	94

TMF2N494	TMF94	        97

TMF2N602	TMF2N602	106

TMF2N804	TMF2N804	116

TMF2P719	TMF2P719	110

TMF2Q296	TMF2Q296	86

TMF2Q714	TMF2Q714	109

TMF2Q715	TMF2Q714	108

TMF2Q716	TMF2Q714	109

TMF2Q733	TMF2Q733	113

TMF2Q753	TMF2Q753	113

TMF2Q759	TMF2Q753	113

TMF2R521	TMF2R521	102

TMF2T497	TMF2T497	100

TMF2W583	TMF2W583	104

TMF2W587	TMF2W583	104

TMF2W726	TMF2W726	111

TMF94	        TMF94	        97

Open in new window

0
Comment
Question by:tarashea
2 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
Comment Utility
select * from tablename
order by left(fieldname,1)
0
 

Author Closing Comment

by:tarashea
Comment Utility
excellent!  thanks a bunch!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now