-- 计算字段-- 拼接字段SELECT CONCAT(vend_name, ' (',vend_country,')')FROM VendorsORDER BY vend_name;SELECT CONCAT(vend_name,vend_country)FROM VendorsORDER BY vend_name;-- CONCAT(str1,str2,...) 拼接查询的值SELECT CONCAT(vend_name,vend_country)FROM VendorsORDER BY vend_name;-- RTRIM(str) 去掉值右边的所有空格 LTRIM(str) 去掉值左边的所有空格SELECT RTRIM(vend_name),RTRIM(vend_country)FROM VendorsORDER BY vend_name;SELECT RTRIM(vend_name)FROM Vendors-- 使用别名 ASSELECT CONCAT(RTRIM(vend_name),' (',RTRIM(vend_country),')')AS vend_titleFROM VendorsORDER BY vend_name;-- 执行算术运算SELECT prod_id,quantity,item_priceFROM OrderItemsWHERE order_num = 20008;-- 价格汇总SELECT prod_id,quantity,item_price,quantity * item_price AS expanded_priceFROM OrderItemsWHERE order_num = 20008;-- 文本处理函数/*常用文本处理函数`LEFT`(str,len) 返回字符串左边的字符LENGTH(str) 返回字符串的长度LOWER(str) 将字符串转换为小写LTRIM(str) 去掉字符串左边的空格`RIGHT`(str,len) 返回字符串右边的字符RTRIM(str) 去掉字符串右边的空格SOUNDEX(str) 返回字符串的soundex值UPPER(str) 将字符串转换为大写*/-- UPPER(str) 将所有字符转换为大写SELECT vend_name,UPPER(vend_name) AS vend_name_upcaseFROM VendorsORDER BY vend_name;SELECT LEFT(vend_name,1),vend_nameFROM VendorsORDER BY vend_name;-- SOUNDEX(str) 返回读音相近的结果SELECT cust_name,cust_contactFROM CustomersWHERE cust_contact = 'Michael Green';-- 返回空的结果SELECT cust_name,cust_contactFROM CustomersWHERE SOUNDEX(cust_contact) = SOUNDEX('Michael Green');-- 日期与时间处理函数SELECT order_numFROM OrdersWHERE YEAR(order_date) = 2012;-- 数值处理函数/*ABS() 返回一个数的绝对值COS() 返回一个角度的余弦EXP() 返回一个数的指数值PI() 返回圆周率SIN() 返回一个角度的正弦SQRT() 返回一个数的平方根TAN() 返回一个角度的正切*/