Skip to content

Tag: oracle

Oracle – Data that contains multiple results from IN

I have a dataset of different transaction ids of type 1,2,3,4,5,6,7 as well as many other columns What I’m trying to do is create different scenarios such as Contains transactions 1 only Contains 1,5 and 7 I’ve started off with a CTE called ALL_CONTRACTS that contains transaction ids of type 1,2,3…

Group By Month between two dates

I have a table that lists all employees and their respective start and end dates I want to be able to count the number of active employees in each month. Is there a way to do this via a single query (eg groupBy) rather than generating multiple queries for each month? As an example, the table above should retu…

How to fetch single records using case statements

I want to fetch single record from the table test_table if any one of the value is null in the column e_value then it should print No else Yes My Attempt: Current Output: Expected Output: Answer you can use GROUP BY and COUNT: The count will return number of non-null values db<>fiddle here

translate query from Oracle to Postgres

I need to translate this query from Oracle to Postgres: can someone help me? thanks in advance for your attention and support Answer In postgres the operateur ~ performs a regex comparison as thus replaces the Oracle function regexp_like(). Your query therefore becomes. I would like to alert your attention th…

Optimizing select union select oracle

I had an interview recently and the recruiter told me to make a query on a table USERS with two fields (name, age) which should return a list with two columns | NAME | MAJOR OR MINOR | My response was this : Then, he told me that is correct, but we can do better! So, my question is: How

selected splitted value in oracle

I have two columns A, B in oracle where A value has values like that xx-target-xx xx any data but target is exists i neet to return only ‘target’ from text i tired this but the result returns xx not target Answer Use REGEXP_SUBSTR. You want the second string of any characters except the minus sign…