首页 > 数据库技术 > 详细

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

时间:2015-04-20 16:23:05      阅读:170      评论: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)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!