Wasn't sure what title to give this. I'm currently writing a query using the table below in SQL Server Management Studio 2012.
If an employee has Qualification 'BDE' then that supersedes Qualification 'RVT' and 'RVT' doesn't need to show in my output for EmpID 1. It does need to show for EMP2 because they don't have Qualification 'BDE'
I've tried various ways using Union and a row partition, I'm sure this isn't a particularly tough request but I'm running out of ideas
EmpID Department ObtainedDate ExpiryDate Qualification DaystoExpire
1 HR 2019-06-12 2024-06-12 BDE 1819
1 HR 2017-06-09 2021-09-18 FGA 821
1 HR 2019-06-18 2021-09-18 RVT 821
1 HR 2019-01-28 2020-01-28 HIJ 222
1 HR 2019-06-03 2019-07-03 TTT 13
2 payroll 2018-10-18 2019-10-18 RVT 120
What I would like
EmpID Department ObtainedDate ExpiryDate Qualification DaystoExpire
1 HR 2019-06-12 2024-06-12 BDE 1819
1 HR 2017-06-09 2021-09-18 FGA 821
1 HR 2019-01-28 2020-01-28 HIJ 222
1 HR 2019-06-03 2019-07-03 TTT 13
2 payroll 2018-10-18 2019-10-18 RVT 120