select UserID,aTime as time,aValue as value,aType as type from TabA
               where userid=1
union all
select userid,btime,bvalue,null from tabb where userid=1

解决方案 »

  1.   

    --忘了排序
    select UserID,aTime as [time],aValue as value,aType as type from TabA
                   where userid=1
    union all
    select userid,btime,bvalue,null from tabb where userid=1
    order by [time] desc
      

  2.   

    select *
    from 
    (
    select userid,[time]=atime,[value]=avalue,[type] from table1
    union all
    select *,null from table2
    ) a
    where userid='1'
    order by [time] desc
      

  3.   

    有union的话,要放到语句的最后面