Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 14th, 2012, 02:03 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Case statement in where clause (Help)

hi all..i need to write a query whereby using case statement in where clause...can anyone guide me? what i want is in my table i need to base on one column(co_role) to determine my where clause..eg:-
Code:
delete from co_employee where (co_salary > 5000 or co_transfer = 'Y') and co_department = 'HR' and co_role = 'Manager'
delete from co_employee where co_class = 'Contract' and co_salary > 2000 and co_department = 'HR' and co_role = 'Staff'
so i was thinking to write in this way (merge 2 in 1) but its not working:-
Code:
delete from co_employee where case (co_role) when 'Manager' then  ((co_salary > 5000 or co_transfer = 'Y') and co_department = 'HR') when 'Staff' then (co_class = 'Contract' and 'co_salary > 2000 and co_department = 'HR')
else null end
Thanks
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Case Statement In Where Clause Logic dwj119 SQL Server 2000 4 October 27th, 2011 04:14 PM
Case in Where Clause acko SQL Server 2000 12 September 12th, 2011 02:43 PM
CASE in where clause. rupen Oracle 2 August 27th, 2009 05:39 AM
Problems using case statement in where clause vghiya SQL Server 2000 3 May 28th, 2007 06:12 AM
Case in Where Clause demiwolf SQL Server 2000 3 March 23rd, 2006 12:45 PM



All times are GMT -4. The time now is 04:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.