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 |
wided
Posting Yak Master
218 Posts |
Posted - 2010-06-04 : 11:51:06
|
Helloi have to select records with top(n), but i must use UNIONselect top(10) col1, col2from table1UNIONselect top(10) col1, col2from table2I want tp have only 10 records from table1 and table2how ca, i write it, this query return 10 from table1 et 10 from table2Thanks |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-06-04 : 11:53:05
|
[code]select top(10) col1, col2from(select col1, col2from table1UNIONselect col1, col2from table2)order by col[/code] |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2010-06-04 : 12:58:37
|
THANKS VIJAYISONLYi try it but i have an error near order by |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-06-04 : 13:29:40
|
Whats the error? Did you replace it with your proper column name?edit: Oops ..maybe because I dint specify the alias.Tryselect top(10) col1, col2from(select col1, col2from table1UNIONselect col1, col2from table2) torder by col |
|
|
|
|
|