zoukankan      html  css  js  c++  java
  • 按照字母表取出顾客ID的首字母的个数

    use Northwind;

    if object_id('tb_Letters',N'U') is not null
    begin
     drop table tb_Letters;
     end;

    create table tb_Letters(
        letter char(1)
    );

    insert into tb_Letters select 'A';
    insert into tb_Letters select 'B';
    insert into tb_Letters select 'C';
    insert into tb_Letters select 'D';
    insert into tb_Letters select 'E';
    insert into tb_Letters select 'F';
    insert into tb_Letters select 'G';
    insert into tb_Letters select 'H';
    insert into tb_Letters select 'I';
    insert into tb_Letters select 'J';
    insert into tb_Letters select 'K';
    insert into tb_Letters select 'L';
    insert into tb_Letters select 'M';
    insert into tb_Letters select 'N';
    insert into tb_Letters select 'O';
    insert into tb_Letters select 'P';
    insert into tb_Letters select 'Q';
    insert into tb_Letters select 'S';
    insert into tb_Letters select 'T';
    insert into tb_Letters select 'U';
    insert into tb_Letters select 'V';
    insert into tb_Letters select 'W';
    insert into tb_Letters select 'X';
    insert into tb_Letters select 'Y';
    insert into tb_Letters select 'Z';

    select C.letter CustomerNameStartWith, isnull(B.num,0) CustomersCount
    from tb_Letters C
    left join(
    select CustomerNameStartWith, count(*) num
    from(
        select
            left(customerid,1) CustomerNameStartWith
        from dbo.customers
        ) A
    group by A.CustomerNameStartWith) B on C.letter = B.CustomerNameStartWith;

    if object_id('tb_Letters',N'U') is not null
    begin
     drop table tb_Letters;
     end;
  • 相关阅读:
    黑盒测试和白盒测试的区别
    alpha测试和beta测试的区别
    selenium退出语句区别
    QTP8.2--安装流程
    Xshell无法连接Linux虚拟机问题
    Linux-----centos6.2---安装Linux的流程
    MySql错误处理--错误代码和消息
    基于Linux系统--web环境搭建
    前端底层-作用域 this 原型笔试题练习
    前端底层-冒泡与捕获
  • 原文地址:https://www.cnblogs.com/sskset/p/2009796.html
Copyright © 2011-2022 走看看