• sql查询练习


    1、有以表结构如下

    id  goodsid  scount  type

    6     3            40     out

    5     2            30     in

    4     1            45     out

    3     3            20     out

    2     2            20     in

    1     1            10     in

    要查询到如下结果
    goodsid 进货 出库 库存

    解:

    select  goodsid,sum(a.sin) as aa,sum(a.sout) as bb ,sum(a.sin)-sum(a.sout)
    from
    (select id,goodsid, case type when 'in' then scount else '0' end as sin,case type when 'out' then scount else '0' end as sout
    from test2) as a
    group by a.goodsid

    2、有表结构如下

    name  result type

     张三   95     语文
     张三   85     数学
     张三   87     英语
     李四   67     数学
     李四   85     英语
     王五   86     语文
     王五   78     数学

    要求查询出所有学科成绩都再80以上的学生名单

    解:

    select distinct(name)
    from test3
    where name not in(
      select NAME
      from test3
      where result<80
      )


     

  • 相关阅读:
    清除浮动
    版心和布局流程
    浮动(float)
    盒子模型(CSS重点)
    CSS 三大特性
    CSS 背景(background)
    移动web开发之rem布局
    .移动端常见布局
    移动端基础
    CSS高级技巧
  • 原文地址:https://www.cnblogs.com/yidianfeng/p/2236305.html
Copyright © 2020-2023  润新知