select * from (select id,time from a union select id time from b) a order by id
解决方案 »
- 关于日期的操作,怎样一下子生成365天,插入到表里
- [玻璃鱼V]关于存储过程命名规则的问题
- 表里只有一个自增主键字段,如何给这个表添加记录?
- 面试题60分!请大家帮忙
- sqlserver2008 跨网订阅问题
- update触发器遇到难题,请大家帮忙
- 我要用SQL语句查询一个字段XX、数值为123的记录,表为ZZC 的语句 急,马上给分
- OLE DB 中,如何通过IP连到SQL SERVER 数据库上
- help ! 高分!
- Sql中sum(nvarchar类型)查询上月的rkzj(入库总价)
- 请问各位老师,SqlServer2000的视图中怎么在where条件中使用随机数阿,能否用随机函数阿,是什么随机函数阿。请赐教。
- 先关联后查询,还是先查询后关联?
sorry
刚才没有看要求
order by time;
只有在 UNION 语句的结尾,才允许使用 ORDER BY 子句以定义最终结果的顺序。不能在组建 UNION 语句的单独查询中使用这些子句。
order by time
select * from(
select id,time from a union select id time from b
) a order by time
select * from (select id,time from a union select id time from b) order by time;select * from (select id,time from a union select id time from b) a order by time;
select * from (select id,time from a union select id time from b) a order by a.time
想知道
select * from (select id,time from a union select id time from b) a order by time;
中, 多出的 a 怎么解释执行的?
个人感觉没有什么区别可以这样写:
select * from (select id,time from a union select id time from b) a order by a.time
----------------------------------------------------------老兄,你这么写是不对的 ,直接用order by time就行。
select * from (select id,time from a union select id,time from b) a order by a.time--可以的