数据库(查询 算术表达式 别名 字符串连接 (消除重复行) 排序 统计函数)

本文介绍SQL的基本操作,包括查询、算术表达式、别名使用、字符串连接、消除重复行、条件查询、排序及统计函数等核心内容。适用于初学者快速上手。

1.查询

查询所有
select * from emp;

查询几列

select name,sex,age from emp;

2.算术表达式


查询一年的金额

select salary*12 from emp

3.别名

select  e.name,e.sex,e.age from emp as e;

4.字符串连接(将姓和名并在一列)

select  last_name || ' '|| first_name  from emp;

5.消除重复行

select distinct id from emp

6.条件查询(and or not)

select * from employee where id>2 and id <4;
select * from employee where id<>3;
select * from employee where id >3 or id <45;
select * from employee where id not is 4;

7.排序

select * from emp order by asc;(小到大 升序)

select * from emp order by desc;(大到小 降序)

8.统计函数

count 总数、max 最大、min最小、avg平均
select count(name)from employee;
select max(age) from employee;
select min(age) from employee;
select avg(age) from employee;



评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值