Skip to content

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’…