You can create a unique index on the table
create unique index only_one_active
on your_table( case when status = 'Y'
then accountNumber
else null
end );
That will allow you to have as many rows as you like with the same account number and a status of N but only one row per account number with a status of Y.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…