跳转至

Length

概述

Length 函数用于计算字符串的长度,即字符串中字符的数量。

语法说明

Length(<字符串>)

参数说明

参数 必需 参数类型 说明
字符串 字段、表达式、常量 需要计算长度的字符串

示例

示例:计算产品名称的长度

假设在一个产品数据表中,产品名称存储在名为 ProductName 的字段中。我们希望计算每个产品名称的长度,可以使用如下表达式:

示例公式

Length(ProductName)

数据示例

ProductID ProductName
P001 "iPhone 13"
P002 "Galaxy S21"
P003 "Pixel 5"
P004 "Surface Pro 7"
P005 "PlayStation 5"

计算结果

通过上述 Length 函数表达式,结果将会是:

ProductID ProductName NameLength
P001 "iPhone 13" 9
P002 "Galaxy S21" 10
P003 "Pixel 5" 7
P004 "Surface Pro 7" 13
P005 "PlayStation 5" 13

Length(ProductName) 将计算 ProductName 字段中每个字符串的字符数量。