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…
Tag: oracle
Oracle sql – get months id between two dates
I have date range eg. ‘2021-01-05’ and ‘2021-02-10’. Two months January and February. Need resaults: Answer You want to iterate through the months. This is done with a recursive query in SQL:
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…
Oracle 12 – Reset a sequence Column with row_number() over Partition
I have this table (with order by product, seq): As you can see because of some delete statments I need to reset the seq column and have a seq from 1 for every product/group like this: I tried to create a new counter with this code: and the result was like this: But when I try it with Update I
Why i am getting error while executing pl/sql program?
Answer In your code you are missing the semicolon in insert statement & radius value assignment statement – Demo.
Use column references in Oracle SQL select query to avoid re-calculation
I want to create a summarised database backup report, which includes data from multiple database tables which has no relation to each other. For example, I want to include the name of the database from v$database view: And the size of the database: And consider there is no common column between those two view…
Querying a list of geometry objects from Oracle based on list of x and y coordinates
We are using an Oracle database table with SDO_GEOMETRY objects. I would like to return the rows where the column with the geometry object contains a certain point (x, y coordinate). I know I can query the table using a single point geometry like this: But let’s say I have a list of coordinates and I wo…
PLS00215: String length constraints must be in range (1..32767)
I am new to pl/sql. I want to create a procedure that has three parameters called ‘startMonth’, ‘endMonth’, ‘thirdMonth’. In the procedure, I am executing a sql query which is in ‘run_sql’ column in table_query. Values for ‘startMonth’, ‘endMon…
SQL logic to fail a check if any of the related customers has failed
I have the requirement to flag the customers Y only when all the related customers have also passed the check. below are the two tables: relationship table : Check table I want output like below: output justification: since 1,2,3 are related customers and since one of them (3) has n in table 2 , so all the re…
Oracle SQL query to get comma-separated string in single query
I have a data which is represented as below: I have a query as follows which has to be tweaked to get parent and child names respectively My output should look as follows: I basically want to split the lk.name based on seperator (,) and 1st string before seperator is parentName and 2nd string after seperator …