Is it possible to order by max length of character

# Thread: Is it possible to order by max length of character

1. Senior Member
Join Date
Dec 1969
Posts
360

## Is it possible to order by max length of character

I would like to select a table and sort from largest length of characters to smallest length of characters.....is this even possible?<BR><BR>For example:<BR>W<BR>ZXCVB<BR>WE<BR>PO<BR>LKJ<BR>SDFG< BR><BR>I want:<BR>ZXCVB<BR>SDFG<BR>LKJ<BR>PO<BR>WE<BR>W<BR> <BR>

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## Have you tried it?

should work<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
360

Have I tried what?

4. Senior Member
Join Date
Dec 1969
Posts
11,247

What&#039;s confusing?<BR><BR>Have you tried a sort from largest length of characters to smallest length charcter in the query?<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
360

## Well...

You are asking if I tried my question...which I can reply, I do not know how....thus asking the question. Can you give me an example of what you think I should have tried?

6. Senior Member
Join Date
Dec 1969
Posts
360

## OK...I am an a#@

I have it now....I was stuck in my head on lenght....not datalength.

7. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Well...

assuming its a varchar<BR><BR>ORDER BY Len(&#060;field&#062;) DESC<BR><BR>or<BR><BR>ORDER BY Len(RTrim(&#060;field&#062;)) DESC<BR><BR>for a char

8. Senior Member
Join Date
Dec 1969
Posts
360

## Help again....followup to first 'stupid'

here is what i have:<BR><BR>SELECT DATALENGTH(ModelNumber) AS Expr1, ModelNumber, Design, Series<BR>FROM BOM_Models<BR>WHERE (ProductLine = &#039;dcv&#039;)<BR>ORDER BY LEN(RTRIM(ModelNumber)) DESC, Series<BR><BR>how do I break this down one more step...I only want to see one instance of each series. There are duplicate values in the series, and I only need to know if it exists once.....it is early, so I hope that made sense

9. Senior Member
Join Date
Dec 1969
Posts
360

## Help again....followup to first 'stupid'

here is what i have:<BR><BR>SELECT DATALENGTH(ModelNumber) AS Expr1, ModelNumber, Design, Series<BR>FROM BOM_Models<BR>WHERE (ProductLine = &#039;dcv&#039;)<BR>ORDER BY LEN(RTRIM(ModelNumber)) DESC, Series<BR><BR>how do I break this down one more step...I only want to see one instance of each series. There are duplicate values in the series, and I only need to know if it exists once.....it is early, so I hope that made sense

10. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## SELECT DISTINCT ... ? (eop)

.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•