码迷,mamicode.com
首页 > 数据库 > 详细

数据库 关键 排序,去重,分组,

时间:2015-04-20 16:25:04      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

create database mmm
create table xxx
(
code int primary key identity(1,1),
name varchar(50) not null,
sex varchar(50) not null,
age int not null,
hight decimal(18,2) not null,
wight int not null,

)
go
insert into xxx values(佐助,,20,175,100);
insert into xxx values(鸣人,,21,177,110);
insert into xxx values(小樱,,19,165,80);
insert into xxx values(宁次,,22,179,200);
insert into xxx values(迪达拉,,23,180,130);
select *from xxx
update xxx set name=我爱罗 where name=鸣人--吧鸣人换成我爱罗
delete from xxx where code=4--删除掉第四行
select*from xxx where name like 小%--找寻名字表里面有小的
select top 3*from xxx--只显示前三行
select top 2 code from xxx where age>19--显示表里面年龄大于19岁的两行
select *from xxx  order by age--按照年龄开始排序
select distinct name from xxx--只显示名字
select *from xxx order by age,wight desc--按照年龄体重排序
select wight from xxx group by wight --按照体重排序
select age from xxx group by age --按照年龄排序
select name from xxx group by name --按照名字排序
select *from xxx where age-3<20--找寻年龄减3小于20岁的
select *from xxx where age in(19,20)--寻表里面年龄是19和20岁的
select *from xxx where name in(佐助)

 

数据库 关键 排序,去重,分组,

标签:

原文地址:http://www.cnblogs.com/w-wz/p/4441790.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!