Skip to content

Oracle SQL query partially including the desired results

My requirement is to display country name, total number of invoices and their average amount. Moreover, I need to return only those countries where the average invoice amount is greater than the average invoice amount of all invoices. Query for Oracle Database Result: Austria 1 9500 Expected: Austria 2 4825 S…

Best way to merge two SQL queries into one query

I have two small SQL queries that I would like to merge to be a single query that I will eventually use in a stored procedure. I have tried a CASE and IF/ELSE but could not get it to work. Below is the code. What I want to achieve is have the first column ‘Count of Open Order Lines’ based

How to only display current and valid data from 2 tables in sql

I have these two tables: Table imp_source: Table imp_update: I need to write a query to have this result: All values of imp_update The values of imp_source when there is no update for seq column of a product/class combination. Update 1: As you can see, the row in imp_source is not in result Because in imp_upd…