-5

Can anyone assist me with this below?

I have 10 records in a table with same acc no and different branches. If I fired the query it should not return any values while where condition is matched.

For example:

 SELECT * 
 FROM temp 
 WHERE branch != "xxx"

It should not return other 9 records also.

Can someone help me?

Thanks

Mansoor
  • 4,061
  • 1
  • 17
  • 27
Hanish
  • 1
  • 2
  • 1
    So, what's the problem ? – Ravi Mar 29 '17 at 04:38
  • Please show us some **sample data** and the expected and current output of your query – marc_s Mar 29 '17 at 04:48
  • Please read [this](http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/) for some tips on improving your question. It's helpful to tag database questions with both the appropriate software (MySQL, Oracle, DB2, ...) and version, e.g. `sql-server-2014`. Differences in syntax and features often affect the answers. – HABO Mar 29 '17 at 13:20

2 Answers2

0

Using group by statement.

Select * from temp where Branch != "xxx" group by acc no

Or you can your top 1 so the query will show only 1 record

Select top 1 * from temp where branch != "xxx"

Icon
  • 103
  • 9
-1

Use this

Select * from temp 
Where branch != 'xxx'
Mizanur Rahman
  • 272
  • 2
  • 11
  • Please use the [edit] link to explain how this code works and don't just give the code, as an explanation is more likely to help future readers. See also [answer]. [source](http://stackoverflow.com/users/5244995) – Jed Fox Mar 29 '17 at 15:02