Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am unable to combine two SQL queries into a single one which reflects some great ideas. 

Assume that I have a query A, and query B. Query A returns the total number of working hours. Query B returns the total number of hours where workers could work.

I just want query A over query B. I need to have the information of the percentage of capacity that was worked. 

I can write query A and B independently, but I am unable to figure out the prewritten queries to come up with a new SQL query that uses them together. So tell me how can I write that query.

1 Answer

0 votes
by (11.7k points)

Try out the following code down below:

SELECT worked/available AS PercentageCapacity

FROM ( SELECT worked FROM A ), 

     ( SELECT available FROM B )

If you want to get more insights into SQL, check out this SQL Course from Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...