zoukankan      html  css  js  c++  java
  • MySQL期末测试

    (1)查询所有产品的产品编号和销售额,并将销售额增加10%后设置别名为“增长额“

    select 产品编号,销售额,销售额*0.1 as 增长额  from pro_sal;
    

    (2)查询“华中、华北、东南”地区的销售商名称和地区

    select 销售商名称,地区 from saler where 地区 in ('华中','华北','东南')
    

    (3)查找销售商名称的第二个字符是’建’并且只有三个字符的销售商编号和名称

    select 销售商编号,销售商名称 from  saler where 销售商名称 like '_建_' 
    

    (4)查询有电话的销售商信息

    select * from saler where 电话 is not null
    

    (5)查询销售额在2000到5000的并且数量大于100的产品编号和销售日期。

    select 产品编号,销售日期 from pro_sal where 销售额 between 2000 and 5000 and 数量>100
    

    (6)求销售了产品的销售商总数。

    select count(销售商编号) as 销售商总数 from pro_sal
    

    (7)求产品编号为“0001”的产品的平均销售额、最高销售额、最低销售额。:

    select avg(销售额) 平均,max(销售额) 最高,min(销售额) 最低 from pro_sal
    

    (8)查询销售产品种类超过2类的销售商编号和种类数。并按购买种类数从大到小排序。

    (9)查询销售商的销售商编号和名称、销售的产品编号和数量。

    select s.销售商编号,s.销售商名称,ps.产品编号,ps.数量 from saler s,pro_sal ps where s.销售商编号=ps.销售商编号
    

    10)查询至少销售过1次“0001”号产品的销售商编号和购买次数,并按购买次数多少降序排列。

    select a.销售商编号,count(*) 购买次数 from pro_sal a where a.产品编号=0001 group by a.销售商编号 order by count(*) desc
    

    (11)查询与‘喜田有限公司’在同一地区的销售商名称,地区和负责人。

    select s.销售商名称,s.地区,s.负责人 from saler s where s.地区 like(select 地区 from saler
     where 销售商名称='喜田有限公司')and s.销售商名称!='喜田有限公司'
    

    (12)查询销售商的销售情况,要求包括销售了产品的销售商和没有销售的销售商,显示他们的销售商编号、销售商名称、产品编号、销售日期。

    select s.销售商编号,s.销售商名称,ps.产品编号,ps.销售日期 from saler s,pro_sal ps where s.销售商编号=ps.销售商编号
    

    (13)查询销售额小于平均销售额的产品编号、产品名称和价格、销售额

    select a.产品编号,a.产品名称,a.价格,ps.销售额 from pros a ,pro_sal ps where a.产品编号=ps.产品编号 and ps.销售额<(select avg(销售额) from pro_sal)
    

    (14)查询没被销售商销售过的产品信息

    select * from pros p where p.产品编号 not in(select ps.产品编号 from pro_sal ps )
    

    (15)查询销售了“0001”但没有销售“0002”号产品的销售商编号和产品编号。

    select ps.销售商编号,产品编号 from pro_sal ps where ps.产品编号=0001 and ps.销售商编号 not in (select 销售商编号 from pro_sal ps where ps.产品编号=0002)
    
  • 相关阅读:
    Java初试
    could not insert new action connection could not find any information for the class named
    GIT 从入门到放弃大整理
    'XCTest/XCTest.h' file not found
    The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
    后台数据为空因此程序闪退
    UISearchController Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior
    AFNetworking request failed unacceptable content type text/html
    Xcode找不到模拟器
    如何查看设备的 UDID
  • 原文地址:https://www.cnblogs.com/James-221/p/13647441.html
Copyright © 2011-2022 走看看