Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

order by alphabet-number

Posted on 2004-09-29
2
Medium Priority
?
1,631 Views
Last Modified: 2008-01-16
I have a sql statement as follows:

Select       Client, sum(Amt1) as A, sum(Amt2) as B
from       Mytable
where       test = '76’
group by Client
order by substring(Client,2,1)

which returns something like this:

Client      A      B
M1      626      4
J1      1800      42
L1      1425      25
K1      1028      16
K2      566      11
M2      247      1
J2      794      4
L2      708      6
K3      282      9
J3      392      10
L3      331      6
M3      134      2
K4      173      2
M4      27      0
J4      216      1
L4      193      13
M5      13      0
J5      41      1
L5      65      2
K5      32      0

 Ok,This returns all the 1’s , 2’s, 3’s and so on together for the Client, but doesn’t come out in alphabetical order.  How do I make it to return alphabetically -number(in Client )? Like as follows

Client
J1
K1
L1
M1
J2
K2
L2
M2
.
.
.
and so on.

Any help would be appreciated. Thanks

PP
0
Comment
Question by:pmandair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 300 total points
ID: 12180605
Select      Client, sum(Amt1) as A, sum(Amt2) as B
from      Mytable
where      test = '76’
group by Client
order by substring(Client,2,1), substring(client,1,1)

Cheers
0
 
LVL 17

Accepted Solution

by:
BillAn1 earned 300 total points
ID: 12180615
try
Select      Client, sum(Amt1) as A, sum(Amt2) as B
from      Mytable
where      test = '76’
group by Client
order by substring(Client,2,1), client
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

604 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