|
-
Oct 8th, 2002, 06:03 AM
#1
Thread Starter
Member
A SQL Query Question!
I have this query:
SELECT LEFT(CallerTelNumber, 2) AS Series
FROM Call
ORDER BY CallerTelNumber
The result is when I run it:
78
78
78
79
79
79
79
79
91
91
...
But what I want, is to group them by that expression I used in the select statement itself 'LEFT(CallerTelNumber, 2) AS Series' to get the following:
78
79
91
...
so i tried using this query...
SELECT LEFT(CallerTelNumber, 2) AS Series
FROM Call
GROUP BY Series
ORDER BY CallerTelNumber
I thought it would work but it didn't, so can someone direct me please as to how I can group a resultset by expression, or if there is a workaround, I'd appreicate the tip...
Thx a lot
V.P.
-----------------
To steal ideas from one person is plagiarism;
to steal from many is research.
Visual Poet :^)
-
Oct 8th, 2002, 06:10 AM
#2
Would a "SELECT DISTINCT LEFT(etc") do the trick for you?
-
Oct 8th, 2002, 06:11 AM
#3
Fanatic Member
Try...
SELECT DISTINCT LEFT(CallerTelNumber, 2) AS Series
FROM Call
ORDER BY CallerTelNumber
-
Oct 8th, 2002, 06:15 AM
#4
Thread Starter
Member
-
Oct 8th, 2002, 09:18 AM
#5
Lively Member
Friend of mine was looking over the shoulder and this was his suggestion
SELECT LEFT(CallerTelNumber, 2) AS Series
FROM Call
GROUP BY LEFT(CallerTelNumber, 2)
ORDER BY CallerTelNumber
EDIT: didn't work so he suggested this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|