zoukankan      html  css  js  c++  java
  • sql Test

    IF NOT OBJECT_ID('[t_Brand]') IS NULL    
    DROP TABLE [t_Brand]
    GO
    CREATE 
    TABLE [t_Brand]
    (
    [ID] int identity(1,1) primary key not null,
    [brandName] Nvarchar(20) null
    )
    go
    IF NOT OBJECT_ID('[t_Product]') IS NULL    
    DROP TABLE [t_Product]
    GO
    CREATE TABLE [t_Product]
    (
    [ID] int identity(1,1) primary key not null,
    [ProductName] Nvarchar(20) null
    )
    go
    INSERT [t_Brand]
    SELECT '喜来登珠宝 ' 
    union all SELECT '香菲草  ' 
    union all SELECT '夏普' 
    union all SELECT '仙蒂罗娜' 
    union all SELECT '小鸡卡迪' 
    union all SELECT '小龙哈彼' 
    go
    insert into [t_Product]
    SELECT '喜来登珠宝 ' 
    union all SELECT '香菲草  ' 
    union all SELECT '夏普' 
    union all SELECT '仙蒂罗娜' 
    union all SELECT '小鸡卡迪' 
    union all SELECT '小龙哈彼'
    union all SELECT '香菲草  '
    union all SELECT '夏普' 
    union all SELECT '仙蒂罗娜' 
    union all SELECT '小鸡卡迪'
    union all SELECT '小龙哈彼'
    union all SELECT '小龙哈彼' 
    union all SELECT '香菲草  ' 
    union all SELECT '仙蒂罗娜' 
    union all SELECT '小鸡卡迪' 
    union all SELECT '小龙哈彼' 
    union all SELECT '香菲草  ' 
    union all SELECT '夏普' 
    union all SELECT '夏普' 
    go
    select a.brandName as 品牌数,
    (
    select count(1)  from t_product  t where t. productname=a.brandname) 产品数 
    from T_brand aorder by 产品数 desc
    go
    /*品牌数    产品数
      香菲草      4
      夏普        4
      小龙哈彼    4
      仙蒂罗娜    3
      小鸡卡迪    3
      喜来登珠宝  1
    */
    
  • 相关阅读:
    js中的函数节流
    使用React写的一个小小的登录验证密码组件
    React如何进行事件传参
    微信小程序实现文字跑马灯
    正则表达式验证邮箱和手机号
    小程序事件传参
    漏覆盖专区
    jmetr _MD5加密_获取签名
    JMeter 中_time 函数的使用(时间戳、当前时间)
    获取响应数据___JSON Extractor 后置处理器
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/1807063.html
Copyright © 2011-2022 走看看