Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-05-02 : 00:02:35
|
| Hai i have requirment...in emp table for some employee there willnt be any value for the salary column. In my report i have three input criteria. one is select all the value from tbl where salary > somevalue.2. where salary < somevalue.3. Salary 'NA' in this conditioni want to display all the records from the table.i want to use case statment to solve this..For 'NA' i need to select all the records. means condition shd be like this.where salary is not null and salary is null..how can i do this |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-02 : 00:07:56
|
[code]select *from employeewhere (@criteria = 1 and salary > @somevalue)or (@criteria = 2 and salary < @somevalue)or (@somevalue is null) -- criteria = 3 everything[/code] KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
Sarakumar
Posting Yak Master
108 Posts |
|
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-05-02 : 03:39:29
|
Hai Related to this, i have one more question in the Case statement is it possible to use two condition..means,case @name when 'R' then 'Rahima'when 'Z' then 'Zahir' or 'Zen' end something like thisquote: Originally posted by khtan
select *from employeewhere (@criteria = 1 and salary > @somevalue)or (@criteria = 2 and salary < @somevalue)or (@somevalue is null) -- criteria = 3 everything KH
|
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-02 : 03:45:00
|
| yes you can use mutiple Conditions within single case.. Case statement is similar to Swtich in programming languages like C++.. for more details on Case look in SQL Server Book onlineIf Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-02 : 04:31:31
|
| >>when 'Z' then 'Zahir' or 'Zen' end Thats not possibleYou can usewhen 'Z' then 'Zahir or Zen' endMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|