USING DATA FROM TWO TABLES

Hi!

I know this is a very simple question but I am new to SSRS and need a little direction. Any information you can provide will be appreciated tremendously.

I have two tables, DEPARTMENTS and SALES.

DEPARMENTS has two columns, DEPARMENT_ID and DEPARTMENT_NAME.

SALES has multiple columns including DEPARTMENT_ID, and SALE_TOTAL.

How might I display the DEPARTMENT_NAME from the DEPARTMENTS table and the SALE_TOTAL of that specific department next to it? I just need the SUM of all the SALE_TOTAL entries from the SALES table where the DEPARTMENT_ID is whatever.

Thank you in advance!

P

July 5th, 2013 1:44am

Hi Patrick, 

You can do a straight join the tables to get the required information:

select a.Deparment_Id,a.Department_name,sum(b.Sale_Total) AS Total
from Deparments a inner join Sales b
on a.Deparment_Id = b.Deparment_Id 
Group by a.Deparment_Id,a.Department_name

 

Free Windows Admin Tool Kit Click here and download it now
July 5th, 2013 1:51am

I knew it was simple :) thank you so much for your help.
July 5th, 2013 2:34am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics