Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
i am little bit confused about a single sql query.
Table
SQL
NoBill     Activity
0          xyz
0          xyz
1          Cancelled
1          ABC
1          Cancelled

i want to remove row which one contains no bill=1 and Activity = ABC
i want recoed like this
SQL
NoBill     Activity
0          xyz
0          xyz
1          Cancelled
1          Cancelled

i have also write query and getting same record which i want
SQL
SELECT * FROM CountySOAPNote WHERE NoBill=1
UNION ALL
SELECT * FROM CountySOAPNote WHERE NoBill=0 AND Activity LIKE '%cancelled%'

i want onle single select statement.
please help me.

Thanks & Regard
Shambhoo
Posted

just a quick fix:
SQL
SELECT * 
FROM CountySOAPNote 
WHERE NoBill=0
  OR ( NoBill=1 AND Activity LIKE '%cancelled%' )
 
Share this answer
 
v2
Comments
Shambhoo kumar 29-May-15 4:37am    
Thanks for your quick response.
i got it.

There are some little bit mistake in query

where NoBill=0 or (NoBill=1 and Activity like '%cancelled%')
Andy Lanng 29-May-15 4:38am    
That's not what your original post does, but that's not important.

The main thing is you know the technique. Now you can use it however you like ^_^

Please accept the solution :D
Shambhoo kumar 29-May-15 4:41am    
Thanks sir. i got it. :)
Another quick fix

SQL
SELECT *
FROM   TABLE
WHERE  NOT (NOBILL = 1 AND ACTIVITY = 'ABC')
 
Share this answer
 
Comments
Shambhoo kumar 29-May-15 5:19am    
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900