zoukankan      html  css  js  c++  java
  • sql 查询包含字符的数量统计

    DECLARE @word VARCHAR(2000);DECLARE @word VARCHAR(2000);
    SELECT @word
        = 'I do not like to get the news, because there has never been an era when so many things were going so right for so many of the wrong persons';
    SELECT @word = REPLACE(@word, The_character, The_digit)
      FROM (VALUES (2, 'A'), (2, 'B'), (2, 'C'), (3, 'D'), (3, 'E'), (3, 'F'), (4, 'G'), (4, 'H'), (4, 'I'), (5, 'J')
                 , (5, 'K'), (5, 'L'), (6, 'M'), (6, 'N'), (6, 'O'), (7, 'P'), (7, 'Q'), (7, 'R'), (7, 'S'), (8, 'T')
                 , (8, 'U'), (8, 'V'), (9, 'W'), (9, 'X'), (9, 'Y'), (9, 'Z')) mapping (The_digit, The_character);
    SELECT @word AS TheTextVersion;
    
    
    
    DECLARE @word VARCHAR(2000);
    SELECT @word
        = 'I do not like to get the news, because there has never been an era when so many things were going so right for so many of the wrong persons';
    SELECT @word = REPLACE(@word, The_character, The_digit)
      FROM (VALUES (2, 'A'), (2, 'B'), (2, 'C'), (3, 'D'), (3, 'E'), (3, 'F'), (4, 'G'), (4, 'H'), (4, 'I'), (5, 'J')
                 , (5, 'K'), (5, 'L'), (6, 'M'), (6, 'N'), (6, 'O'), (7, 'P'), (7, 'Q'), (7, 'R'), (7, 'S'), (8, 'T')
                 , (8, 'U'), (8, 'V'), (9, 'W'), (9, 'X'), (9, 'Y'), (9, 'Z')) mapping (The_digit, The_character);
    SELECT @word AS TheTextVersion;
    
    declare @test varchar(100);
    select @test='hello,i love you';
    select @test=REPLACE(@test,'i','ooo')
    select @test
    
    declare @test1 varchar(100);
    select @test1='ab aab aabb abb aba';
    select @test1=REPLACE(@test1,b,a)  from  (values(1,'a'),(2,'b'))mapping(a,b)
    select @test1
    
    select * from (values(1,2),(3,4)) mapping(t,v)
  • 相关阅读:
    Lua编程入门学习笔记1
    面向对象S.O.L.I.D原则
    asp.net Mvc学习之URL路由
    Spring 3.x MVC 入门2 通过示例初步感受spring mvc
    Spring 3.x MVC 入门1 图解MVC整体流程
    JSP自定义标签开发入门
    编译安装php5.3.8(含phpfpm)
    CentOS 安装eaccelerator PHP加速
    Nginx + fastcgi 处理php
    sql server charindex函数和patindex函数详解(转)
  • 原文地址:https://www.cnblogs.com/Hackerman/p/6013007.html
Copyright © 2011-2022 走看看