zoukankan      html  css  js  c++  java
  • oracle decode 函数

    DECODE 

    语法: 

    SELECT DECODE( <EXPR,SEARCH1,RESULT1,SEARCH2,RESULT2,...[,DEFAULT]>)
    FROM <TABLE_NAME>
    

    e.g.:

    select orderno,decode(ostatus,'p','准备处理','c','已完成') 

    from order_master

    此函数可用于行转列:

    select * from score

    SELECT   u_id, stu_name, 
             SUM (DECODE (score_type, '语文', score, 0)) AS 语文, /*or use max()*/
             SUM (DECODE (score_type, '数学', score, 0)) AS 数学,
             SUM (DECODE (score_type, '外语', score, 0)) AS 外语
        FROM score
    --where u_id>1
    GROUP BY u_id, stu_name
    --having u_id >1
    ORDER BY u_id
    

  • 相关阅读:
    Minimum Path Sum
    Unique Paths II
    Unique Paths
    Rotate List
    Permutation Sequence
    Merge Intervals
    Jump Game
    Group Anagrams
    Combination Sum II
    评分
  • 原文地址:https://www.cnblogs.com/wucg/p/2102218.html
Copyright © 2011-2022 走看看