删除重复数据

时间:2018-05-17 02:51:38

标签: mysql sql multiple-tables

我创建了一个名为" Retail Stores"我创建了以下表格名称:" store"," account"," order" " store_salesperson"," store_warehouse_shipper。请参阅下表中的照片:

enter image description here

我的问题是你如何制作或整合" hub1"作为一个数据ONLY或ONE只在HUB列上产生而不影响表的其他列?

我的意思是商店的数量,名称,订单数量,总订单数量,盒子数量,纬度,经度仍然显示相同的结果但是" Hub1"数据只会在集线器列上显示一次。

以下是我自学成才的练习代码:

   select (s.id) as '# of stores', 
    s.name,
   (a1.display_name) as hub,
   count(o.id) as '# of orders',
   sum(total_product_cost) as 'Total Order Size',
   sum(o.no_of_boxes) as '# of boxes',
   s.point_y as latitude,
   s.point_x as longitude

   from `order` as o 
   join store_warehouse_shipper as sws on sws.id = o.associate_id
   join store as s on s.id = sws.store_id
   join store_salesperson as ss on ss.store_id = s.id
   join account as a1 on a1.id=ss.salesperson_account_id
   left join store_salesperson as ss1 on ss1.store_id = s.id and 
   ss1.id>ss.id 

   where
   date(delivered_by) = curdate()
   and a1.display_name like '%hub%'

   group by s.id, a1.id
   order by a1.id ASC

0 个答案:

没有答案