#group详解
select goods_id,goods_name,shop_price from goods;//所有行
select max(shop_price) from goods;//查询商品价格最贵的商品
select min(shop_price) from goods;//查询商品价格最便宜的商品
//下面的语法使用是错误的,因为goods_id,和goods_name搜索结果是第一个id,和name.
//只有max(shop_price)是正确的.
select goods_id,goods_name,max(shop_price) from goods;
#查询最贵的商品的价格
select goods_id,cat_id,goods_name,shop_price from goods;
//每一个栏目下面最高的商品价格取出来(cat_id)
select cat_id,max(shop_price) from goods group by cat_id;
#查询最大(最新)的商品的编号
select max(goods_id) from goods;
#查出最便宜的商品的价格
select min(shop_price) from goods;
#查出最旧(最小)的商品的编号
select min(goods_id) from goods;
#查询该店所有商品的库存量
select sum(goods_number) from goods;
#查询所有商品的平均价
select avg(shop_price) from goods;
#查询该店一共有多少种商品
select count (*) from goods;
select goods_id,goods_name,goods_number from goods;
#按栏目查询最贵商品
select cat_id,max(shop_price) from goods group by cat_id;
#按栏目查询最贵商品
select cat_id,max(shop_price) from goods group by cat_id;
#按栏目查询最低商品价格
select cat_id,min(shop_price) from goods group by cat_id;
#分栏目查询商品平均价格(每个栏目下的平均价格)
select cat_id,avg(shop_price) from goods group by cat_id;
#栏目查询商品库存量
select cat_id,sum(shop_number) from goods group by cat_id;
#每个栏目下的商品种类
select cat_id,count(*) from goods group by cat_id;
#每个栏目下的商品种类
select cat_id,count(*) from goods group by cat_id;