Code:
CASE_ID BEFORE BETWEEN AFTER 53222 N N Y 53222 Y N N 53222 Y N N 53222 Y N N 53222 Y N N 53222 Y N N 53222 Y N N 54233 Y N N 54233 Y N N 54233 Y N N 54233 Y N N 54375 Y N N 54375 Y N N 54375 Y N N 54375 Y N N 54375 Y N N 54375 Y N N 54375 Y N N 54375 Y N N 54992 Y N N 54992 Y N N 54992 Y N N 54992 Y N N 54992 Y N N 54992 Y N N 54992 Y N N
I have a query with the above data. I want to consolidate it and have a row for each distinct Case_ID based on the following condition,
BEFORE column = 'Y', if any of the rows for that Case_ID has a 'Y', else BEFORE column = 'N'
BETWEEN column = 'Y', if any of the rows for that Case_ID has a 'Y', else BEFORE column = 'N'
AFTER column = 'Y', if any of the rows for that Case_ID has a 'Y', else BEFORE column = 'N'.
So for Case_ID = 53222 abd 54233, the consolidated rows should look like,
53222, Y, N, Y
54233, Y, N, N
Thanks in advance
Comment