【发布时间】:2021-01-28 20:48:26
【问题描述】:
我的目标是得到这个数据集中“the”、“when”和“wolf”的总数。
我将在返回查询中总共有 14 个计数。
编辑:“the”也被添加到单词“they”的计数中
CREATE TABLE #BaseTable([Text] VARCHAR (500))
INSERT INTO #BaseTable ([Text]) VALUES
('When the villagers heard the cry, they came running up the hill to drive the wolf away.'),
('But, when they arrived, they saw no wolf.'),
('The boy was amused when seeing their angry faces.')
Microsoft SQL Server 2014 - 12.0.2000.8 (Intel X86)
Feb 20 2014 19:20:46
Copyright (c) Microsoft Corporation
Express Edition on Windows NT 6.3 <X64> (Build 9600: ) (WOW64) (Hypervisor)
【问题讨论】:
-
这不是我想说的典型 RDBMS 任务。无论如何,您需要使用 REGEX 定义它,因为它是一项复杂的任务,例如,
They也包含the但您想按照我的理解排除它。 -
对此我深表歉意。如果我把“the”这个词改成“but”怎么样? @TedoG。编辑:“他们”一词中的“the”也被添加到计数中。在帖子中添加到
-
你有没有尝试过?你想要区分大小写吗?是否要将
they包含在the中? -
我尝试分别数单词,但我很难数出所有三个单词@HoneyBadger
-
什么版本的 SQL Server?
标签: sql sql-server string tsql count