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;
  • 相关阅读:
    es6数组方法
    es5数组方法
    es6中的generator函数
    async、await
    CSS---文本属性及其属性值
    MySQL---查询某个字段内容中存不存在某个数据,与like不同(FIND_IN_SET(str,strlist))
    CSS---background属性及其属性值
    TP---时间查询(当日、本周、本月、本年)
    PHP---各种输出详解
    type=“text”只能输入数字!
  • 原文地址:https://www.cnblogs.com/sskset/p/2009796.html
Copyright © 2011-2022 走看看