Hi Guys,I have just completed a query and I have realized that they are duplicates with cardnumbers because they are ppl in the database that are recorded as having both a credit card and then not having a credit card. Let me explain...-If a person appears twice in the result set that is one row as the person card number along with a 'Y' and the below it the same person appears again with the same card number,first name but the difference is that they have a 'N' in the credit card field.In the final result set I want them to appear with a 'Y'-If a person appears once with a 'Y' then the result should appear with a 'Y'-If a person appears once with a 'N' the result should appear with a 'N'I would like to delete those rows that has 'no' and keep the ones that 'yes'. How would I go about doing that with out deleting the person completely.sample of present results.FN MN LN CreditCard? CardNumberANNE M ABOAB N 1TERROL W ALLEYNE N 2TERROL W ALLEYNE Y 2WENDY D ALLEYNE Y 3RICHARD D ALLSOPP N 4JOHN NULL BEALE N 5JOHN NULL BEALE Y 5
sample of how I would like results to look.FN MN LN CreditCard? CardNumberANNE M ABOAB N 1TERROL W ALLEYNE Y 2WENDY D ALLEYNE Y 3RICHARD D ALLSOPP N 4JOHN NULL BEALE Y 5
Initial Queryselect distinct c.cardnumber ,FirstName ,InitialsName ,LastName ,AddressLine1 ,AddressLine2 ,AddressLine3 ,HomePhone ,CellPhone ,WorkPhone ,Gender ,CycleCode ,CardClass ,c.ClassCode ,IsCreditCardKey = case when (IsCreditCardKey = 'yes' then 'Y' else 'N' end from customer c inner join AlternateAccessKeys a on a.cardnumber=c.cardnumber inner join SubsidiaryByCustomerByClassTransactionDetail s on s.cardnumber=c.cardnumberwhere s.subsidiaryid in (select subsidiaryid from subsidiary where subsidiaryid in (1411,1419) )group by c.cardnumber ,FirstName ,InitialsName ,LastName ,AddressLine1 ,AddressLine2 ,AddressLine3 ,HomePhone ,CellPhone ,WorkPhone ,Gender ,CycleCode ,CardClass ,c.ClassCode ,IsCreditCardKeyorder by c.cardnumber