MySQL Forums
Forum List  »  Newbie

Copying seasonprices to next year
Posted by: Floris Stork
Date: June 24, 2021 07:06AM

Hi,
I am New to Mysql and hope that someone can help me with this challange.

This database is for holiday rentals, a house can have several seasons

It looks like this
ID | HOUSE | DATE_FROM | DATE_TO | PRICE
1241 | 26 | 2019-04-04 | 2019-07-08 | 520
1242 | 26 | 2021-04-03 | 2021-07-07 | 520
1243 | 15 | 2019-04-04 | 2019-07-08 | 800
1244 | 15 | 2021-04-03 | 2021-07-07 | 800
1245 | 15 | 2022-04-02 | 2019-07-06 | 800
1246 | 10 | 2021-04-28 | 2021-07-12 | 300

I want to select all houses that have a price in 2021 And Not yet a price in 2022,
then copy the the seasonprice of 2021 and create a new season for the same period in 2022.
The same period in 2022 is 2021 DATE_FROM +1year-1day and DATE_TO +1year-1day

so in this case my query should do the following:
find house 26 and create a new season:
1247 | 26 | 2022-04-02 | 2022-07-06 | 520
skip house 15 because it already has a season filled in for 2022
find house 10 and create a new season:
1248 | 10 | 2022-04-27 | 2022-07-11 | 300

it looks a bit complicated to me, and I am not sure how to write the query,

your help is much appreciated

Options: ReplyQuote


Subject
Written By
Posted
Copying seasonprices to next year
June 24, 2021 07:06AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.