case的应用

select (case
          when (m.code_dir = 'F') then
           n.code_startpointid
          else
           n.code_endpointid
        end) as startid,
       
        (case
          when (m.code_dir = 'F') then
           n.code_endpointid
          else
           n.code_startpointid
        end) as endid
 
   from rte_seg m, segment n
  where m.segment_id = n.segment_id
  

posted @ 2013-03-21 09:43  忆如梨花  阅读(148)  评论(0编辑  收藏  举报