实验案例二:在products表中单表查询
实验环境
以实验案例一的结果为环境。
需求描述
1,查询成本低于10元的水果信息。
2,将所有蔬菜的成本上调1元。
3,查询成本大于3元并小于40元的产品信息,并按照成本从高到低的顺序显示结果。
4,查询成本最高的5个产品信息。
5,查询有哪些产品种类。
6,将products表中所有水果的名称、种类和出厂曰期信息并插入新表products_new中。
推荐步骤
执行T一SQL语句完成上述需求.步骤略。
1,查询成本低于10元的水果信息。
select * from products where 成本<10 and 种类='水果'
2,将所有蔬菜的成本上调1元。
update products set 成本=成本+1
where 种类='蔬菜'
3,查询成本大于3元并小于40元的产品信息,并按照成本从高到低的顺序显示结果。
select * from products
where 成本 between 3 and 40
order by 成本 desc
4,查询成本最高的5个产品信息。
select top 5 * from products order by 成本 desc
5,查询有哪些产品种类。
select 种类 from products
6,将products表中所有水果的名称、种类和出厂曰期信息并插入新表products_new中。
select 名称,种类,出厂日期 into products_new from products where 种类='水果'
select * from products_new