一道SQL数据库的题,求大神解答下呗?
1 --你们老师傻啊,有些东西不可以用char,得用varchar,我这里给你改了create table 表1(商品代号 char(8) parimary key,分类名 varchar(8),单价 float,数量 int)create table 表2(商品代号 char(8) primary key,产地 varchar(6),品牌 varchar(6))4select * from 表1 where 分类名='电视机'5select 商品代号,分类名,单价 from 表1 where 单价1500 and 数量>108select * from 表1 where len(分类名)...全部
1 --你们老师傻啊,有些东西不可以用char,得用varchar,我这里给你改了create table 表1(商品代号 char(8) parimary key,分类名 varchar(8),单价 float,数量 int)create table 表2(商品代号 char(8) primary key,产地 varchar(6),品牌 varchar(6))4select * from 表1 where 分类名='电视机'5select 商品代号,分类名,单价 from 表1 where 单价1500 and 数量>108select * from 表1 where len(分类名)=3 and left(分类名,1)='电' --按你老师的说法,如果用char类型,根本就没含3个字符的,都是6了9select * from 表1 where 分类名 like '%波%'10select * from 表1 where len(分类名)=5 and substring(分类名,3,1) in ('电','波')11select * from 表1 where len(分类名)=5 and substring(分类名,3,1) not in ('电','波')12select 分类名,max(数量) 最大数量,min(数量) 最小数量,avg(数量) 平均数量,sum(数量) 总数量 from 表1 group by 分类名13select 分类名,count(*) 种数,max(单价) 最高单价,min(单价) 最低单价,avg(单价) 平均单价 from 表1 where 分类名='电视机' group by 分类名14select max(数量*单价) 最高价值,min(数量*单价) 最低价值,sum(数量*单价) 总价值 from 表115select * from 表1 where 单价>(select max(单价) from 表1 where 分类名='洗衣机')16select * from 表1 where 数量'春兰'18select * from 表1 where 单价 between 1000 and 2000。
收起