Skip to content

Generate dates in-between date and date after

Based on the table below I want to generate the dates in between, by dividing the revenue by the number of days from the date in the current row and the row below. Example: Revenue in US on 1 January 2020 is 120. The next revenue date for the US is 5 January 2020. There are 4 days in betweeen.

SQL SELF JOIN – driving me crazy

Can someone please tell me how to solve this question? And the thought process – like how do you think while solving this. It is driving me crazy. šŸ™ Question – The attendance table logs the number of people counted in a crowd each day an event is held. Write a query to return a table showing the d…

How to left join when only matched one record from right table

I want to know How to left join when only matched one record from right table. For example, tableA id value 1 34 2 42 3 60 tableB id value tableA_id 1 20 1 2 31 1 3 50 2 I want to get result like below using left outer join. tableA_id tableA_value tableB_value 1 34 null 2 42 50

disaggregate 3d time periods into daily

table_1 shows the aggregation of the revenue by different geographies I would like to disaggregate the 3d period to daily: table_2 as a next step, I would like to also change the table_2 format into table_3: From table_1 to table_2, I am not sure. From table_2 to table_3, I am thinking of: With the code above…

Update with a subquery and a join

How do I update table1 with results of this query – I want to do something like this – Answer This question has been answered many times in SO… anyway, the query should be built this way One option Other option Surely there are other additional ways…

SQL WHERE statement returning both or conditions

I’m trying to return a single row based on this where statement The issue is I have to get a row based on multiple criteria and the more that match determines the final match. The statement above returns a row just fine if it matches the bottom or statement, but if it matches the first OR it returns res…