Skip to content

Convert a set of columns into rows in ORACLE SQL

I have a query that returns a table that looks somewhat like below. In the image, I want the Input table to look like the Output table — Essentially, I want all the data from columns to get …

Hide null values on parameter value

I have a stored parameter with a where clause between start and end dates that includes null values: WHERE a.date is null OR a.date between @StartDate AND @EndDate These null values are obviously …

Oracle SQL: LAG over a range of values

How do we use analytic function LAG over the range of values. It should return null if there is no record in the partition with an earlier in_date otherwise, year and month of the previous in_date …

Add Sequential Letter column to table

In C I can switch between int and char to build a list of sequential integers and then convert them to ASCII characters that will be sequential according to the alphabet. Is there a way to do this in …

Query to modify where clause to specify relation

I have 2 tables: users & user_roles users: id name 1 John 2 Doe user_roles: user_id role 1 admin 1 finance 1 accounting 2 admin 2 finance 2 admin I want to get the users that have admin & finance roles in the output(with distinct). So the result will be only user with ID of 2 (Doe) What is the