Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
divan
Posting Yak Master
153 Posts |
Posted - 2013-04-09 : 11:17:58
|
I have a table that has the following fieldsAccount_number,account_cd.. the account_CD can be E or I and an account_number can be assigned an E or an I per rowExampleAccount_number Account_cd1234 I1234 E3456 I6777 I6777 E7888 E8999 ISo I want to only choose the account_numbers that have account_CD of E and do not have an Account_cd of I. so in the example above I only want to select account 7888 as that is the only Account_number that has an E and does not have an I |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2013-04-09 : 11:20:13
|
SELECT Account_number FROM myTable GROUP BY Account_number HAVING MAX(Account_cd)='E' |
|
|
divan
Posting Yak Master
153 Posts |
Posted - 2013-04-09 : 11:48:02
|
Thank you it worked perfect... |
|
|
|
|
|