How can we find the between the overlap lap b/w the dates . overlap means when start date and end date are within same range for below example row 1 has no over lap. Row 2to 5 can be considered as one set of over lap as there start date and end are over lap with themselves Row 6 &
Tag: sql
Is there an SQL query equivalent for Disable Related Foreign Keys option available in the Oracle SQL Developer [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question TLDR: Is there a script or SQL query to mimic the functionality “Disable the related fo…
Finding whether duplicates exists in 2 select statements
Could you please help me with SQL statement to find duplicate names present in first Select statement and the second. For example : I need to find whether student with same name in Class 1 is present or not in Class 2 or 3. and Second select statement is : If there is matching occurrences for any name then I
How to find a non-existing value from another table in mysql using ONE single QUERY
I want to find number of types of produce of each farmer, names of farmer and the total number of produces but I am getting stuck in the part trying to display farmers who do not produce anything in the supplies and then in another query I want to extend it to display farmers with highest produces but without…
how to find the difference of median price of a municipality from the current month and the next one?
How to get the absolute difference between the median house price for tat month in that municipality and the median house price for the next month in that municipality? I have a table with house data. it contains the price and municipality for each house and date it got sold. I want to get the difference of t…
How to query all rows where a given column matches at least all the values in a given array with PostgreSQL?
The request below: returns a list like this: How to get the ids for which id must have at least a and b, and more generally the content of a given array ? From the example above, I would get: Answer For two values, you can use windowing boolean aggregation: A more generic approach uses array aggregation:
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’…
Subtract values from one column based on values in another (TSQL)
I have table where I need to subtract values in one column based on conditions applied to the other. For example, I want to subtract values with code fst and trd, meaning (12 – 23). I don’t want to declare separate variables. Is it possible to make this with a query? Answer One method is condition…
SQL IN in WHERE. How smart is the optimizer?
I have the following query to execute: UPDATE scenario_group SET project_id = @projectId WHERE scenario_group_id = @scenarioGroupId AND @projectId IN (SELECT …