注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 CCIE-Lab考试将新增10分钟..
 帮助

SQL 问题及解答 2


2006-09-30 23:54:11
 标签:SQL   [推送到技术圈]

18单表数据查询
update products
set unitprice=unitprice*0.9
where unitprice>30
 19设计表结构
字段名
中文意思
字段类型
是否为空
备注
id
记录编号
int
not null
主键
entrytime
通过时间
datetime
not null
 
cardid
通过卡号
char(8)
not null
假设卡号长度为8
 20考查order by 和group by 以及having子句
select city,count(city) as 客户数
from customers
group by city
having count(city)<3
order by 客户数
 21考查order by 和group by子句
select  city,count(city) as 客户数
from customers
group by city
order by 客户数 desc
 22考查distinct 和group by子句
select title as 职位
from emloyees
group by title
select distinct title
form employees
 23考查count函数
select count(*) as 数量
from employees a,employees b
where a.reportsto=b.employees and b.lastname=’fuller’
select a.lastname
from employees as a,employees as b
where a.reportsto=b.employeeid and b.lastname=’fuller’
24考查update子句
update a
set reportsto = b.employeeid
from employees a, employees b
where a.lastname = ‘callahan’ and  b.lastname = ‘buchanan’
 25考查数据库自联接
select a.lastname as 员工, b.lastname as 下属
from employees as a inner join employees as b
on b.reportsto=a.employeeid
select a.lastname as 员工, b.lastname as 下属
from employees as a, employees as b
where b.reportsto=a.employeeid
 




    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: