Issue with join

Shweta

Well-known Member
Joined
Jun 5, 2011
Messages
514
Hi All,

I have three table in my database
1) products with two columns - product, price
2) region with two columns - SalesPerson, Region
3) transactions with five columns - date, SalesPerson, Product, Discount, Units

I want region wise net revenue. Calculation for revenue is : price*(1-discount)*Units

I am using below query for it. but it is not working. Kindly help me out on this.

select R.Region,(P.Price*(1-T.Discount)*T.Units) as [Net Revenue]
from region as R
inner join Transactions as T
on R.SalesRep = T.SalesRep
inner join Products as P
on p.Products = t.Product
group by r.Region

Thanks in advance!

Regards,
Shweta
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
How is it not working? What is happening?

If you want total revenue by Region, I think you will need to use the SUM function on your calculation, i.e.
Code:
[COLOR=#333333]select R.Region,[/COLOR][COLOR=#ff0000][B]Sum[/B][/COLOR][COLOR=#333333](P.Price*(1-T.Discount)*T.Units) as [Net Revenue][/COLOR]
 
Upvote 0
You are welcome!

Yes, with Aggregate Queries, for all the columns/calculations you are displaying, you are either Grouping them, or applying some aggregate function on them (SUM, COUNT, etc).
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top