Skip to content
Advertisement

Oracle SQL join and expand [closed]

I have 2 tables – sales and ratio.

sales table has 2 columns – state, sales. This has total sales by state.

ratio table has 3 columns – state, type, pct. This has the % of each type of sales in a state (online, store, other). For each state, total of pct is 1 (100%).

How do I best get a result table which has these columns – state, type, sales?

Thanks!

Sample data: Sales:

Ratio:

Result:

Advertisement

Answer

Join, as you said.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement