SQLTeam.com | Weblogs | Forums

Sum and Join for certain dates and items on multiple tables


#1

What is a SQL query to retrieve the total revenue of Nevada Fried Chicken in 2015 and group the data by revenue center?


#2

This sounds very much like a homework q. We can't provide answers for that, only general guidance. You'll have to code the query yourself and maybe we can help correct it / refine it for you.


#3

select rc.rev_center_desc, SUM(t.pos_revenue - t.discount)
from [transaction] t
inner join rev_center rc on rc.rev_center_cd = t.rev_center_cd
where rc.rev_center_desc like 'nevada fried chicken%'
-- and DATEPART(yyyy, date) = 2015 -- not a SArg
and date between '2015-01-01' and '2015-12-31'
group by rc.rev_center_desc