October 5, 2006 at 11:21 am
How can I manipulate rows from a query ,for example, I have 3 rows in a query if want that the third row can be the first one, or the second can be the the third, can I do that in sql server 2000...
October 5, 2006 at 1:06 pm
Hi
Can u give us an example with those rows?
Fabiano
October 5, 2006 at 4:37 pm
If I use order by the last row will be the first one, but I don't want this, I want create this dynamictly, is not to be necesary use three rows you can use more...but in a query I want to have the control of the query, it's something like arrays...
October 5, 2006 at 5:23 pm
What in the table tells you this is first row and that is third row?
In other words: can you post the SELECT statement for 3rd row?
_____________
Code for TallyGenerator
October 6, 2006 at 3:53 am
Could you explain WHY do you want to do this?
SQL Server has no specific ordering of rows returned by query, unless you specify ORDER BY. That's why Sergiy is asking what tells you that this is the first/second/third row. If you run the same query several times in a row, without any changes to data, you can get a different order of rows every time. It is true that often the rows do come back in some special order (like ordered by some clustered index etc.), but you can not rely on that. Next time you run the same query, rows can be ordered differently.
ORDER BY is the only way how to achieve specified ordering; even if you want to use some external program to "shuffle" the resultset outside SQL, you may need to include ORDER BY in the select to achieve some defined order before you start to shuffle. Anyway, I still don't understand why anyone would want to do that.. could you elaborate on the purpose of such action?
October 6, 2006 at 5:03 am
There is no specific keyword or function in SQL Server that will help you with your desired output, only way out would be have an additional column in your table and store the ordering in that column and order by that column.
Prasad Bhogadi
www.inforaise.com
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply