zoukankan      html  css  js  c++  java
  • sql基本语句

    ---恢复内容开始---

    查询有几个不同的职位名称:

    select distinct name from a;

    group by:

    现在有两个表product和sales,字段分别如下:

    TABLES:product

    字段:id(产品id)、Name(产品名称)

    TABLES:sales

    字段:id(销售id)、product_id(产品id)、DATE(日期)、amount(销售数量)

    1、修改产品D的产品名称为E

    update  product set  Name=E where Name=D ;

    2、插入产品名称为“产品E”的产品数据;

    insert into table(product) field(产品E); 

    3、删除产品名称为"产品E"的数据;

    delete from product where Name = 产品E;

    4、查询2014-1-1至2014-1-3期间单日销售数量大于110的产品;

    select name from product a, sales b  where  a.date > 2014.1.1 and < 2014.1.3   b.amount >110;

    5、查询销售总量最多的产品名称;

    select Name from product a,sales b where amount=max(amount);

    6、查询每种分类的总和:查询每种产品的销售总量;

    select sum(amount) from product a, sales b group by b.proudct_id;

    7、查询销售总量大于300的产品;

    select id  Name from product a right join sales b where  having sum(amount)>300;

    ---------------------------------------------------------

    1、查询多少个产品;

    select distinct Name from product;

    2、统计产品的个数;

    select count(distinct name) from product;

    常用选项
    个人分类
     
    发布选项
     

    ---恢复内容结束---

    查询有几个不同的职位名称:

    select distinct name from a;

    group by:

    现在有两个表product和sales,字段分别如下:

    TABLES:product

    字段:id(产品id)、Name(产品名称)

    TABLES:sales

    字段:id(销售id)、product_id(产品id)、DATE(日期)、amount(销售数量)

    1、修改产品D的产品名称为E

    update  product set  Name=E where Name=D ;

    2、插入产品名称为“产品E”的产品数据;

    insert into table(product) field(产品E); 

    3、删除产品名称为"产品E"的数据;

    delete from product where Name = 产品E;

    4、查询2014-1-1至2014-1-3期间单日销售数量大于110的产品;

    select name from product a, sales b  where  a.date > 2014.1.1 and < 2014.1.3   b.amount >110;

    5、查询销售总量最多的产品名称;

    select Name from product a,sales b where amount=max(amount);

    6、查询每种分类的总和:查询每种产品的销售总量;

    select sum(amount) from product a, sales b group by b.proudct_id;

    7、查询销售总量大于300的产品;

    select id  Name from product a right join sales b where  having sum(amount)>300;

    ---------------------------------------------------------

    1、查询多少个产品;

    select distinct Name from product;

    2、统计产品的个数;

    select count(distinct name) from product;

    常用选项
    个人分类
     
    发布选项
     
  • 相关阅读:
    关于git的简单使用
    手机设备上调试接口,查看错误信息
    用after伪类清除浮动
    js字母大小写转换方法
    使用淘宝 NPM 镜像
    JS判断类型
    JS判断客户端是手机还是PC的2个代码
    微信小程序 WebSocket
    服务器安全管理
    Linux下禁止ping最简单的方法
  • 原文地址:https://www.cnblogs.com/jiangkeji/p/5157533.html
Copyright © 2011-2022 走看看