oracle - Need to write a sql query: There can only be one value for another particular value -


for example, in table addresses there column zip_code. zip codes can anything, 90210, 45430, 45324. there can multiple instances of 90210 or other zip code. zip code, there can one value in state column. if 90210 in zip code column, state column must ca, if there record 90210 , has oh or ga or else, incorrect. looking find these particular zip codes have other 1 single value in other column. not homework question.

select zip_code, count(distinct state) address group zip_code having count(distinct state) > 1; 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -