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;
  • 相关阅读:
    归并排序
    msp430的时钟源设计
    插入排序
    msp430F5438A 的中断初步
    算法导论,第一节第二节课总结
    MSP430F5438A的时钟系统
    msp430F5438A 的ADC 研究
    图像处理基本原理(转载)
    C++标准库简介
    C# 接口 抽象类
  • 原文地址:https://www.cnblogs.com/sskset/p/2009796.html
Copyright © 2011-2022 走看看