SQL 必知必会第八课 使用函数处理数据

SQL 必知必会第八课 使用函数处理数据

select vend_name, upper(vend_name) as vend_name_upcase from vendors order by vend_name;

select cust_name, cust_contact from customers where cust_contact = 'Michael Green';
select cust_name, cust_contact from customers where soundex(cust_contact) = soundex('Michael Green');
##soundex是将文本转换为语音表示的字母数字模式,可以用来搜索发音相似的数据

select order_num from orders where extract(year from order_date) = 2020;
select order_num from orders where year(order_date) = 2020;

##challenges
select cust_id, cust_name,upper(concat(substring(cust_contact,1,2),substring(cust_city,1,3))) as user_login from Customers  ; -- 1
## substring(expression, start, length) start第一位是1 不是0 和其他编程语言不一样

select order_num, order_date from orders order by date(order_date); -- 2

注意点

  1. 数据处理函数在格式化,处理和过滤数据中非常有用,但是在SQL的实现中非常不一致。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值