<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Jcat
    寵辱不驚,閑看庭前花開花落~~
    posts - 173,comments - 67,trackbacks - 0
    -- Test?Case
    create ? table ?sale(
    sale_id?
    char ( 1 )
    ,sale_type?
    char ( 1 )
    )
    --
    insert ? into ?sale? values ?( ' a ' , ' Y ' );
    insert ? into ?sale? values ?( ' b ' , ' N ' );
    insert ? into ?sale? values ?( ' b ' , ' Y ' );
    insert ? into ?sale? values ?( ' b ' , ' Y ' );
    insert ? into ?sale? values ?( ' c ' , ' Y ' );
    insert ? into ?sale? values ?( ' c ' , ' N ' );
    insert ? into ?sale? values ?( ' d ' , ' N ' );
    insert ? into ?sale? values ?( ' d ' , ' N ' );

    Count the number of 'Y' and the number of? 'N' separately
    -- full?join
    select ? * ? from ?
    (
    select ?sale_id,? count ( * )? as ?num_y? from ?sale
    where ?sale_type = ' Y '
    group ? by ?sale_id
    )?sale_y
    full ? join
    (
    select ?sale_id,? count ( * )? as ?num_n? from ?sale
    where ?sale_type = ' N '
    group ? by ?sale_id
    )?sale_n
    using?(sale_id)
    order ? by ?sale_id

    -- decode
    select ?sale_id
    ?,
    sum (decode(sale_type, ' Y ' , 1 , 0 ))? as ?num_y?? -- note?using?sum?to?implement?count
    , sum (decode(sale_type, ' N ' , 1 , 0 ))? as ?num_n
    from ?sale
    group ? by ?sale_id
    order ? by ?sale_id

    -- case
    select ?sale_id
    ?,
    sum ( case ? when ?sale_type = ' Y ' ? then ? 1 ? else ? 0 ? end )? as ?num_y?? -- note?using?sum?to?implement?count
    , sum ( case ? when ?sale_type = ' N ' ? then ? 1 ? else ? 0 ? end )? as ?num_n
    from ?sale
    group ? by ?sale_id
    order ? by ?sale_id

    Separate sale_type column
    -- union?all
    select ?sale_id,?sale_type? as ?type_y,? null
    from ?sale
    where ?sale_type = ' Y '
    union ? all
    select ?sale_id,? null ,?sale_type? as ?type_n
    from ?sale
    where ?sale_type = ' N '
    order ? by ?sale_id

    -- decode
    select ?sale_id
    ,decode(sale_type,
    ' Y ' , ' Y ' , null ) as type_y
    ,decode(sale_type,
    ' N ' , ' N ' , null ) as type_n
    from ?sale
    ?
    -- case
    select ?sale_id
    ,(
    case ? when ?sale_type = ' Y ' ? then ? ' Y ' ? else ? null ? end )? as ?type_y
    ,(
    case ? when ?sale_type = ' N ' ? then ? ' N ' ? else ? null ? end )? as ?type_n
    from ?sale
    posted on 2006-12-05 13:11 Jcat 閱讀(253) 評論(0)  編輯  收藏 所屬分類: Database
    主站蜘蛛池模板: 精品免费国产一区二区三区| 99国产精品免费视频观看| 性色av免费观看| 亚洲精品理论电影在线观看| 好吊妞在线成人免费| 亚洲乱人伦中文字幕无码| 白白国产永久免费视频| 亚洲爆乳精品无码一区二区| 免费永久在线观看黄网站| 免费看美女午夜大片| 亚洲熟伦熟女新五十路熟妇 | 日韩免费高清一级毛片| 一本色道久久88综合亚洲精品高清| 国产精品久久亚洲一区二区| 免费在线一级毛片| 叮咚影视在线观看免费完整版| 亚洲五月六月丁香激情| 99久久久精品免费观看国产| 亚洲欧美日韩久久精品| 免费国产不卡午夜福在线| 中文字幕免费人成乱码中国| 亚洲va无码手机在线电影| 最近免费2019中文字幕大全| 国产成人亚洲综合一区| 免费在线不卡视频| 国产精品免费AV片在线观看| 77777亚洲午夜久久多喷| 免费国产美女爽到喷出水来视频| 国产在线播放线91免费| 久久精品国产亚洲AV电影| 巨胸喷奶水视频www网免费| 美女被免费视频网站a| 亚洲激情中文字幕| 在线成人a毛片免费播放 | 国产偷窥女洗浴在线观看亚洲| 怡红院免费全部视频在线视频| 亚洲一级片在线播放| 久久久久亚洲av毛片大| 无码国产精品一区二区免费式影视 | 18级成人毛片免费观看| 亚洲国产成人久久精品软件|