MySQL Forums
Forum List  »  Newbie

JOIN command question
Posted by: Serafino Spagnol
Date: January 18, 2015 04:09PM

Goodmorning sirs, I'm new to SQL JOIN statement, so after hours spent trying and trying to obtain the result I'm asking help to forum...
I have two tables, 'Irrigations' and 'DailyData',
Lets suppose this data on 'Irrigations' table:
DateTime Quantity
20150101 080000 1.5
20150101 120000 1.1
20150101 160000 1.8
20150102 080000 1.9
20150102 120000 2.0
20150103 080000 1.0
20150103 120000 1.2
20150103 160000 1.4
20150103 190000 1.6

and this data on 'DailyData' table:
DateTime Rain
20150101 000000 0.5
20150102 000000 0.6
20150103 000000 1.1

How can I obtain the following query result ? :
DateTime Quantity Rain
2015 01 01 1.5 0.5
2015 01 01 1.1 NULL
2015 01 01 1.8 NULL
2015 01 02 1.9 0.6
2015 01 02 2.0 NULL
2015 01 03 1.0 1.1
2015 01 03 1.2 NULL
2015 01 03 1.4 NULL
2015 01 03 1.6 NULL
I need to join the rows of the two tables with the same calendar day and have the value of 'Rain' field only in the first occurrence of the day.

Thanks for the help,
Serafino Spagnol

Options: ReplyQuote


Subject
Written By
Posted
JOIN command question
January 18, 2015 04:09PM
January 18, 2015 10:34PM


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.