本文介绍了如何获得每个城市的销售量(促销项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我不是很擅长SQL

我试图获得每个城市的销售金额(促销项目)



Hi everyone
I'm not very good at SQL
I tried to get the amount of sale (promotion item) on each city

select distinct l.city, p.name as promotion_name, s.count
from location l, promotion p, sale s
where s.locationID=l.id and s.promotionID=p.id
and l.city = 'London' or l.city='Leeds'
or l.city = 'Slough' or l.city='Grays'
and p.name= 'super sale' or p.name='best sale'







任何帮助?




Any help ?

推荐答案

select distinct l.city, p.name as promotion_name, count(s.id)
from location l, promotion p, sale s
where s.locationID=l.id and s.promotionID=p.id
and p.name= 'super sale' or p.name='best sale'
Group By l.city, p.name



如果你想要每个城市的销售,那么无需添加条件


If you want each city's sale then no need to add in where condition


and l.city in ('London','Leeds')
and p.name in ('Super sale','Best sale')





它的工作原理:)



Thanx无论如何都要帮助你们



and it works :)

Thanx anyway for your help guys



这篇关于如何获得每个城市的销售量(促销项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 00:14