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 |
|
Jacky
Starting Member
4 Posts |
Posted - 2008-03-12 : 14:39:03
|
| hello,I have 2 tables which contain a lot of articles, and they have same structure.what I want to do is that, select top 10 articles from each table and then union those records to another table, also I need to order these articles in desc order by their added date before i union them.what I know is that for union sql phrase , there is only one order by is allowed, so how could I order those 2 tables before i union them.thanks |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2008-03-12 : 14:52:44
|
Is this what you are trying to do? SELECT *FROM ( SELECT * FROM ( SELECT TOP 10 * FROM TableA ORDER BY AddedDate ) AS A UNION ALL SELECT * FROM ( SELECT TOP 10 * FROM TableB ORDER BY AddedDate ) AS B ) AS TempORDER BY AddDate |
 |
|
|
Jacky
Starting Member
4 Posts |
Posted - 2008-03-12 : 16:27:12
|
| yes, that's what i am trying to dothanks |
 |
|
|
|
|
|