Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Yula
Starting Member
4 Posts |
Posted - 2007-05-09 : 02:38:48
|
Can anybody help me with this?i want to get random rows coming from this query.select columnID, column1from table1unionselect columnID, column2from table2I was wondering if i can get for example 5 random rows from this query.Hope somebody can help.. thanks in advance.. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-09 : 02:46:50
|
select top 5 columnid, col from (select columnID, column1 as colfrom table1unionselect columnID, column2 from table2) as xorder by newid()Peter LarssonHelsingborg, Sweden |
 |
|
Yula
Starting Member
4 Posts |
Posted - 2007-05-09 : 03:26:00
|
quote: Originally posted by Yula Can anybody help me with this?i want to get random rows coming from this query.select columnID, column1from table1unionselect columnID, column2from table2I was wondering if i can get for example 5 random rows from this query.Hope somebody can help.. thanks in advance..
let me change the problem.. I want to get random columnIDs from the query.. |
 |
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-05-09 : 04:12:56
|
Did you check peter's query ? put some sample data and required o/p. |
 |
|
|
|
|