读书人

SQL语句.

发布时间: 2012-01-23 21:57:28 作者: rapoo

求一个SQL语句....
现在有两个表,除了表名不同外,有完全相同的字段(名称,属性)
如:
table1: c1 c2 c3 c4 c5
table2: c1 c2 c3 c4 c5
现在要查询table1和table2中,c3字段= '0000 ',按c5降序排列的前20条记录.

PS:
20条记录中,有可能是table1中的N条,table2中的20-N条;
此20条中是按c5的降序混合排列...

[解决办法]
select top 20 * from(select * from table1 union select * from table2) t order by c5 desc

读书人网 >asp.net

热点推荐