Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case in Where clause

Status
Not open for further replies.

rrchowdhary

Programmer
Aug 26, 2005
20
GB
Hi all

I am struggling to get this query right but without any success. Any help would be really helpful

here is my query

Code:
SELECT * FROM tb_filters
WHERE Id=@filterId AND 

CASE @SectionFilter
  WHEN 'NeedsAndRisks' THEN sq.NeedsAndRisks  
	IN(SELECT item from dbo.fnSplit(@ScoreFilter, ','))
  WHEN 'SupportPlanning' THEN sq.SupportPlanning 
	IN(SELECT item from dbo.fnSplit(@ScoreFilter, ','))

Thanks
RR
 
Code:
SELECT * 
  FROM tb_filters
 WHERE Id = @filterId 
   AND CASE WHEN @SectionFilter = 'NeedsAndRisks' 
            THEN sq.NeedsAndRisks
            WHEN @SectionFilter = 'SupportPlanning' 
            THEN sq.SupportPlanning
            ELSE NULL END
      IN ( SELECT item FROM dbo.fnSplit(@ScoreFilter,',') )
where does the sq table get defined?

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Thanks r937

This worked like a charm.

What I am trying to do is get all the filters matching perticular @SectionFilter and this is being used in a stored proc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top