create database xue1 go --创建数据库 use xue1 go --引用数据库 create table xinxi ( code int, name varchar(20), xuehao decimal(10), brithday decimal(10), ) --创建信息表 insert into xinxi values(1,'张三',2016042701,2016-4-27) insert into xinxi values(2,'李四',2016042702,2016-4-27) insert into xinxi values(3,'王五',2016042703,2016-4-27) insert into xinxi values(4,'马六',2016042704,2016-4-27) insert into xinxi values(5,'赵七',2016042705,2016-4-27) insert into xinxi values(6,'秦八',2016042706,2016-4-27)
--输入信息
--查询所有信息 select * from student --查询学号为6的人的所有信息 select * from student where code=6 --查询学号为8的人的姓名 select name from student where code=8 --查询所有人的姓名 select name from student --查询24岁以上的人的所有信息 select * from student where age>24 --身高超过175的所有人的姓名 select name as 姓名 from student where height>175 --查询总数 select COUNT(name) from student --查询年龄超过24的人数 select COUNT(*) from student where age>24 --order by 排序 默认从小到大排列 select *from student order by age --从大到小排列 desc select *from student order by age desc
聚合函数
--AVG 平均数 select AVG(age) as 平均年龄 from student select AVG(height) as 平均身高 from student --SUM 求和 select SUM(age) from student select SUM(height) from student --MAX 最大值 select MAX(age) from student select MAX(height) from student --MIN 最小值 select MIN(age) from student select MIN(height) from student --COUNT 个数 --查询总数 select COUNT(name) from student --查询年龄超过24的人数 select COUNT(*) from student where age>24 --分组 group by select sex from student group by sex --gre=oup by having 聚合函数 select sex from student group by sex having COUNT(*)>5 --修改表中的数据 update student set age=18 where name='薛岩'
--增加一列 use Z1p10320 go Alter table student add tizhong decimal(18,1) --删除一列 alter table student Drop column tizhong select name as '姓名' from student where age>25 select * from student where age>24
当前时间距离哪一天还剩下多长时间精确到秒
function time() { var date1=new Date(); //开始时间 var date2=new Date(2016,3,30,0,0,0); //结束时间 var date3=date2.getTime()-date1.getTime() //时间差的毫秒数 //计算出相差天数 var days=Math.floor(date3/(24*3600*1000)) //计算出小时数 var leave1=date3%(24*3600*1000) //计算天数后剩余的毫秒数 var hours=Math.floor(leave1/(3600*1000)) //计算相差分钟数 var leave2=leave1%(3600*1000) //计算小时数后剩余的毫秒数 var minutes=Math.floor(leave2/(60*1000)) //计算相差秒数 var leave3=leave2%(60*1000) //计算分钟数后剩余的毫秒数 var seconds=Math.round(leave3/1000) var qqqq=document.getElementById("qqqq"); qqqq.innerHTML="<font color='#FFFFFF' face='经典粗宋简'>4/30前预订独家方案,再送300元 还有</font>"+days+"<font color='#FFFFFF' face='经典粗宋简'>天</font>"+hours+"<font color='#FFFFFF' face='经典粗宋简'>小时<font>"+minutes+"<font color='#FFFFFF' face='经典粗宋简'>分</font>"+seconds+"<font color='#FFFFFF' face='经典粗宋简'>秒</font>"; window.setTimeout("time()",1000); } window.setTimeout("time()",0)