Please consider this pseudo-query: Consider that: “From A” is much more complex and I don’t want to do more joins there. I’m filtering results and foreach record A i just want to return a single row, that’s why I have the exists in the order i want them to evaluate; How can I avo…
Tag: oracle
SQL Create View with a new column to hold values from DateDiff
I have the following SQL code to create a view called v_students and I want to use the DATEDIFF() function to find the difference between the current date and the registration_date and then place those values in a new column called DaysSinceRegistration. I am running into an issue where there is a syntax erro…
How to bybass sql injection error in Javascript
I am getting sql injection error while trying to run the below code in javascript. I am trying to see a way to update this using parameter or some place holders to bybass the injection error but I am …
How to calculate the average value of following n rows based on another column – SQL (Oracle) – updated version of previously answered question
I am trying to calculate average monthly value of PREMIUM for each POLICY_ID in monthly basis as shown below screenshot. When a customer updates his/her yearly PAYMENT_FREQUENCY to a value different than 12, I need to manually calculate the average monthly value for the PREMIUM. In addition, average monthly P…
Why doesn’t Oracle recognize a stored generated column definition?
I have the following generated column defined within a CREATE TABLE statement: ROW_COUNT and PREV_ROW_COUNT are simple NUMBER(18) columns previously defined in the same table. Everything works fine as it’s written. But if I un-comment the STORED option, I get: I need to convert this into a STORED genera…
Oracle Cannot retain data
I have oracle database installed on my system I access it through command line. I had created a user and I created a table Inserted few records. then I exit Problem is that when I try to login again. table is still there. But the data which I had inserted is gone. OUTPUT Answer SQL*Plus has option to auto-com…
Oracle – Parsing Multiple JSON Values in a single SQL query
I have data in PersonalDetails table in JSON format, I am trying to parse the data in a single query, currently I am using JSON_TABLE functions, in my query I am only able to parse only one column, if I try to use JSON_TABLE functions twice it throwing me an error, is their a way to parse all the columns
Eliminate duplicate values and replace them with null values oracle?
I have a table like But my desired table is Rule here is Replacing dest2 by null if it appears once and Replacing dest1, dest2 by null if dest1 appears once… Answer You seem to be null’ing out dest2 after it appears once, and the pair when both appear. Assuming that source provides the ordering, y…
How to return the difference between 2 strings using Oracle SQL only
I have 2 strings for example: ‘Source:Siebel; Name:Mary Jane; Gender:F; Age:24; N;’ ‘Source:Siebel; Name:Marie; Gender:F; Age:24; N;’ The result I need is: Name:Mary Jane; Name:Marie; Most likely I need to reverse below code from Oracle Function to return similarity between strings as …
Limiting records by included/excluded/null date ranges
First, a description of my task. I need to identify customers that have placed orders within the past 2 years. However, I need a subset of those records. There needs to be 1 or more orders placed …