SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Case Statement in a Where Clause?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nokiauk
Starting Member

United Kingdom
9 Posts

Posted - 06/18/2012 :  04:42:02  Show Profile  Reply with Quote
Hi

I've got a SQL report that has various columns the 2 that are important here are :

Person.Gender
Age

I need a statement (case or if) in my where clause that can accomplish the following:

I only want to return rows when if the Person.Gender is Male and under is under 65 and if Person.Gender is Female and age is under 61.

Not sure how to utilize the 2 columns?

Thanks

senthil_nagore
Flowing Fount of Yak Knowledge

India
1006 Posts

Posted - 06/18/2012 :  04:49:59  Show Profile  Visit senthil_nagore's Homepage  Send senthil_nagore a Yahoo! Message  Reply with Quote
You can try some thing like this

Select * from table_name where (gender='male' and age<65) or (gender='female' and age<61)

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000