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;
  • 相关阅读:
    用.NET读取Flash格式文件信息
    通过ASP.NET页面重启服务器
    Webservice优点与缺点
    iClient 6R for Flex移动端开发的Q&A
    GIS十年路
    脚本调用命令行
    FME的简单介绍
    GIS从信息化到领域化(一)
    GIS从信息化到领域化(二)
    理性的看待地理信息共享交换平台建设
  • 原文地址:https://www.cnblogs.com/sskset/p/2009796.html
Copyright © 2011-2022 走看看