Skip to content

Tag: oracle

How to get previous rows date in SQL?

I have a table that stores the effective date column in order. In some cases as mentioned below I effective date is NULL so in that case I am supposed to pick date from previous column and add 1 day and show as effective date. It works fine when there is a date in previous row but when 2 or

How can I calculate the median of all rows?

What I’m trying to accomplish: I’d like to calculate the median number of rows for the last 49 days for each store and hour of the day (0 – 24 hours). What I’ve done so far: My current SQL is below. I’…

Oracle – update the same count of duplicates between two tables

I have two tables UPD_REF and UPD_TO There is no key and we can have duplicates in both tables UPD_TO or UPD_REF. I need to update the same count of rows on UPD_TO corresponding to UPD_REF. If I do a simple update or merge like this: I have all the matching values updated: But I need to get that: Any