--lect top 4 name as '姓名' from firstTable
/*
下面为聚集数据行
*/
--计算出共有多少行
select COUNT(*) from firstTable
select COUNT(name) from firstTable
--计算出id列所有值的和
select SUM(id) from firstTable
--计算出name列的max
select MAX(name) from firstTable
--计算出id列的max
select MAX(id) from firstTable
--计算id列的average的值
select AVG(id) from firstTable
/*
模糊查询 like
*/
select name from firstTable where name like '%z%_a%'
/*
子查询 in/exists
*/
--如果表一中的id有表二中的id值,就打印出对应的name
select name as '表一的姓名' from firstTable where id in(select id from secondTable)
/*
group by 分组
*/
select age,COUNT(*) as '行数',SUM(id) as '和'
from firstTable
group by age