|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ordering values in a cell
Data
10 13 15 3 26 10 13 20 35 29 10 13 5 26 2 10 15 27 34 33 Query Declare @num1 char(5) Set @num1 = (SELECT ltrim(Substring(ltrim(number2), 8, CHARINDEX(' ', ltrim(number2)))) FROM Num2played) SELECT @num1 FROM Num2played Error Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. Any suggestions or fix? Thank you. ![]() ========================================= The data above is in one colum. I would like to rearange the numbers in order. e.g. from "10 13 15 3 26" to "3 10 13 15 26". |
|
#2
|
|||
|
|||
|
Try
Set @num1 IN (SELECT rather than Set @num1 = (SELECT |
|
#3
|
|||
|
|||
|
What are you trying to do?
Quote:
That's not valid T-SQL. |
|
#4
|
|||
|
|||
|
What I am wanting to do.
The data above is in one colum. I would like to rearange the
numbers in order. e.g. from "10 13 15 3 26" to "3 10 13 15 26". I can get the each unique value, but I don't know how to compare it. If that make sense. This is why I am trying to assign each unique value to a variable and then compare the variables from smallest to the largest. I am doing the query piece by piece. It is true, the sql above it bad. |
|
#5
|
|||
|
|||
|
You shouldn't store multiple values in one column. Store each value separately after which it is no problem to get the data in a specific order.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > ordering values in a cell |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|