Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Order by for Ratio Dataset Expand / Collapse
Author
Message
Posted Thursday, September 03, 2009 7:10 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, May 11, 2010 11:50 PM
Points: 15, 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
Post #782130
Posted Thursday, September 03, 2009 9:09 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 11:24 AM
Points: 32,781, Visits: 14,942
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
Post #782277
Posted Thursday, September 03, 2009 9:22 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, May 11, 2010 11:50 PM
Points: 15, 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
Post #782288
Posted Thursday, September 03, 2009 9:30 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 11:24 AM
Points: 32,781, Visits: 14,942
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
Post #782298
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse