Sql语句你知道多少(二)------select语句

使用列别名

1.中文列别名代替英文列别名

select id as 编号,name as 姓名 from tb_PersonalInfo;

2.多表查询中出现重复列名时,前面要带上表名

select tb_Student.id as 学生编号,tb_PersonalInfo.id as 员工编号 from tb_Student,tb_PersonalInfo,where tb_Student.id=tb_PersonalInfo.id

3.查询结果中添加新列

select name,math,englist,chinese,(math+english+chinese) as sumScore from tb_Score;

4.统计结果中添加列

select name,sum(math) as 数学总成绩,sum(english) as 英语总成绩,sum(chinese) as 语文总成绩 from tb_Student Group by name;

在列中计入计算

1.使用字符函数Left、Right、Mid

select name from tb_Student where right(1,枫) like "枫"//查询后一个字为枫的同学,可能是陈枫、罗枫等等

2.使用数字函数(ABS、Len等)

select name from tb_Student where Len(name)>3//查询名字长度大于3

3.使用日期时间函数

select ProductName from tb_Products where year(2010);//查询2010销售的商品

4.使用取出空格函数

select name from tb_Student were trim(name) like trim(txtName.text)//去除空格

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值