Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
i have a table containing data the values like

Question   | Option
-----------|------------
21285	   |88232
21285	   |0
21285	   |88234
21285	   |0
21286	   |88239
21287	   |88250
21287	   |88252
21287	   |88255


i have to on executing i have to eliminate the value that contains zero in the option column like 21285 will be eliminated and only 21286, 21287 with there values should be displayed

thank you
VRN

What I have tried:

i tried creating the comma separated value using XML and splitting the value to check the if the value contains zero but it is not working
Posted
Updated 12-Oct-16 3:22am

Try putting relevant filters using WHERE clause.
Example:
SQL
SELECT Question, Option
FROM MyQuestions
WHERE Option<>0 --required filter here
ORDER BY Question


Hope, it helps :)
 
Share this answer
 
Comments
write2varun 12-Oct-16 9:25am    
using this it will not eliminate all the values but it only eliminate the values which have option as 0
Suvendu Shekhar Giri 12-Oct-16 9:50am    
Then try the 2nd solution by @OrginalGriff. That's what you need I think
Try:
SQL
DELETE FROM MyTable 
WHERE Question IN 
     (SELECT DISTINCT Question 
	  FROM MyTable 
	  WHERE [Option] = 0)
 
Share this answer
 
v2
Comments
write2varun 13-Oct-16 1:25am    
thank you
This really solved my problem
OriginalGriff 13-Oct-16 2:18am    
You're welcome!

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