SQL Case语句查询
参见图片。
我有一张表格,里面装满了与特定部门相关的记录。如果部门名称位于“StandardWork”字段下,但位于“Support -”一词之后,那么用于创建名为 Service 的新列的 SQL 命令是什么,它将忽略“support”一词、空格和破折号,而仅使用部门来对吗?
See image.
I have a table full of records relating to specific departments. If the department name is held under the field 'StandardWork' but after the word 'Support -' what is the SQL command to create a new column called Service which will disregard the word support, the space and the dash and just use the department to the right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果
StandardWork
需要与Service
一起存在,计算列如果要替换
StandardWork
,则:If
StandardWork
need to exist alongsideService
, computed columnIf to replace
StandardWork
, then:我更喜欢使用
STUFF
函数来解决这些问题。此函数将删除字符 1-10 并用空字符串替换它们。
I prefer to use the
STUFF
function to solve these issues.This function will delete the characters 1-10 and replace them with an empty string.
您可以使用替换
或内容(如果您的部门名称中包含
Support -
)。You can use replace
or stuff if you have departments that has
Support -
as a part of the name.在 select 语句中:
Inside a select statement: