SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Order by for Ratio Dataset


Order by for Ratio Dataset

Author
Message
akilamm
akilamm
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 46
Hi
i am trying to arrange ratio dataset in ascending order
example dataset looks like this
50302136 120:0:7:4
50303835 194:0:9:6
50302786 249:0:14:7
50302640 37:0:2:0
50303753 382:0:7:1
50302137 59:0:10:0

i tried with order by ,it is not working
is there any solution to arrange data in ascending order
Steve Jones
Steve Jones
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: Administrators
Points: 63490 Visits: 19115
I'm not sure what I'm looking at here. What are the data types? Is the ratio a char field? If so, then it is ordered as characters.

What ordering are you trying to get, or what are the rules for ordering your ratios?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
akilamm
akilamm
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 46
hi
i am having ratio values as output from proc for example (20:2:1)
i want arrange this values in ascending order or in descending order
Steve Jones
Steve Jones
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: Administrators
Points: 63490 Visits: 19115
These have to be coming back as characters. Therefore they'll be ordered as characters.

20:1:1
comes before
20:2:5

No matter what the math, these are ordered by characters. If you have some rules, you could use charindex and substring to strip out the individual numbers and possibly find a way to order them, but the rules for reducing these to the lowest values would be complex.

Again, if you develop the rules that you need for ordering these, we might be able to help.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search