SQL 问题及解答 2
18、单表数据查询
update products
set unitprice=unitprice*0.9
where unitprice>30
19、设计表结构
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
|


bodaos1180
博客统计信息
热门文章
最新评论
友情链接