Skip to content
Advertisement

ORACLE SQL: Combining 2 rows of 2 separate select queries

Hello I am very new to SQL and I have an issue. I have 3 tables job, revenue and cost. job.unid = cost.job_unid and revenue.job_unid

I want to find the total revenue and cost for each job and then find the profit for each job all on one row:

The headers looking something like this: Job No, Total Revenue, Total Cost, P&L (Rev-Cost)

I tried to make a single query, but after searching on the internet for solutions it seemed like i should query Revenue and Cost seperately and then combine using Union All.

Now I am doing this:

The result is: I am not sure if you can see but it is 2 lines: 1 is the revenue and 1 is the cost.
I want to combine these 2 lines

query result jpg

Advertisement

Answer

Try this.

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