22,209
社区成员
发帖
与我相关
我的任务
分享
销售表 sell
id selldate num price id_huiyuan id_product remark
主键 出库日期 数量 单价 会员ID 产品ID 备注,字段类型text
会员表 huiyuan
id name
主键 会员名
产品表 product
id brand title
主键 品牌 名称
select brand as 品牌,title as 商品名称,selldate as 出库日期,num as 数量,price as 单价,price*num as 总金额,name as 会员,remark as 备注 from sell
inner join huiyuan a on id_huiyuan=a.id
inner join product b on id_product=b.id
--按这个要求来查是不能分组的,实在要分组 直接聚合分组条件就好了
select brand as 品牌,title as 商品名称,selldate as 出库日期,num as 数量,price as 单价,sum(price) as 总金额,name as 会员,remark as 备注 from sell
inner join huiyuan a on id_huiyuan=a.id
inner join product b on id_product=b.id
--按这个要求来查是不能分组的,实在要分组 直接聚合分组条件就好了
select
a.brand as 品牌,
a.title as 商品名称 ,
b.num as 数量,
b.price as 单价,
(b.num * b.price) as 总金额,
c.huiyuan as 会员,
b.remark as 备注
from product a , sell b , huiyuan c where
a.id = b.id_product and c.id = b.id_huiyuan
select brand as 品牌,title as 商品名称,selldate as 出库日期,num as 数量,
price as 单价,num*price as 总金额,name as 会员,remark as 备注
from sell,huiyuan,product
where sell.id_product=product.id and sell.id_huiyuan=huiyuan.id
select c.brand as 品牌,c.title as 商品名称,
a.selldate as 出库日期,a.num as 数量,a.price as 单价,a.num*a.price as 总金额,
b.name as 会员,a.remark as 备注
from sell a
left join huiyuan b on a.id_huiyuan=b.id
left join product c on a.id_product=c.id