I've got a query which selects either week 1 or week 2 or both if available and then i need to find a way of displaying only the week 1 results but knowing which ones are available for both weeks.
Here's my query which may help explain
select *
from table1 t1
where t1.location = 'VH'
and (t1.week = '46' or t1.week = '47');
This gives me the following results
week location
46 VH209A
46 VH209B
46 VH20B
46 VH20C
47 VH209B
47 VH20A
47 VH20C
I only want to show these results
week location
46 VH209A
46 VH209B
46 VH20B
46 VH20C
But i want to know which records are also available for the next week i.e these ones
week location
47 VH209B
47 VH20C
So my desired result would be something like
week location 2weeks
46 VH209A N
46 VH209B Y
46 VH20B N
46 VH20C Y
Hope this makes sense?
Any ideas how can i get the results desired?