首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

联合查询排序有关问题

2012-02-03 
联合查询排序问题select*from( Selecto.Net_Id As netId,o.Use_Person As usePerson,o.Use_Date As u

联合查询排序问题
select
  *  
  from
  ( Select
   
  o.Net_Id As "netId",
  o.Use_Person As "usePerson",
  o.Use_Date As "useDate",
  o.Use_Type As "useType",
  i.Use_Person As "usePerson1",
  i.Use_Date As "useDate1",
  i.Use_Type As "useType1",
  '' As "applyPerson",
  Null As "applyDate",
  '' As "newStatus"  
  From
  Net_Pki o,
  Net_Pki i  
  Where
  o.Id = i.Use_Id (+)  
  And o.use_type = 'O'  
  And o.Net_Id='201104140010'  
  Union 
  Select
  s.Ass_No As "netId",
  '' As "userPerson",
  Null As "useDate",
  '' As "useType",
  '' As "userPerson1",
  Null As "userDate1",
  '' As "useType1",
  s.Apply_Person As "applyPerson",
  s.Apply_Date As "applyDate",
  s.New_Status As "newStatus"  
  From
  Ass_Status_Apply s  
  Where
  s.Ass_No = '201104140010'  
  And s.New_Status='BF'  
  )  
  Order by
  ID ASC  

在oracle数据库中查询时,报 ID:无效标示符
我在 Select
  o.Net_Id As "netId", 中间加了一个o.Id Ad "id" 报查询块具有不正确的结果列数 这个应该怎么改 才能让最后查询出来的数据按照ID升序排列


[解决办法]
必须的呀, Ass_Status_Apply s 这个表哪个字段对应 o.Id As "id"呀
[解决办法]
因为你使用了union,要求2个查询结果集的列数必须一致。

热点排行