There is 2 tables Bookings and BookingNote
Table Bookings contains BookingId and other booking related columns.
Whenever there is an update to the booking, A note is added to the BookingNote Table.
BookingNote table example:
BookingId | Note |
---|---|
123 | Booking Created |
123 | User Details Updated |
123 | Booking Cancelled |
Select B.BookingId ,
Case
When N.Note = 'Booking Created' Then N.Note
When N.Note = 'Booking Cancelled' Then N.Note
End
From Bookings as B
Join Notes as N
On B.BookingId = N.BookingId
Where N.Note = 'Booking Created'
Or N.Note = 'Booking Cancelled'
Result
BookingId | Note |
---|---|
123 | Booking Cancelled |
123 | Booking Created |
How can I get a merged note when there is a 'Booking Created' and 'Booking Cancelled' for a BookingId so that I can get a result like this
BookingId | Note |
---|---|
123 | Booking Cancelled , Booking Created |