Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-13
2
Medium Priority
?
228 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 2000 total points
ID: 21781930
select * from tablename
order by left(fieldname,1)
0
 

Author Closing Comment

by:tarashea
ID: 31467048
excellent!  thanks a bunch!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

782 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