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
 General SQL Server Forums
 New to SQL Server Programming
 How to code?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sadbjp
INNER JOIN

41 Posts

Posted - 05/14/2007 :  13:21:19  Show Profile  Reply with Quote
Hi,

How can I code this:

Set the values of GoalMet comparing the LocalPerf value and SppTarget.Target value with the CompareMethod. If CompareMethod = 1, then LocalPerf >= Target means GoalMet = 1; othwerwise, LocalPerf <= Target means GoalMet = 1.

Thanks in advance.

dinakar
Flowing Fount of Yak Knowledge

USA
2507 Posts

Posted - 05/14/2007 :  13:41:06  Show Profile  Visit dinakar's Homepage  Reply with Quote
you can use a CASE Statement. Is that a type or would it be 1 for both cases? Change your CASE accordingly. you can use the foll as a sample:

SELECT
 GoalMet = CASE WHEN CompareMethod = 1 AND LocalPerf >= Target Then 1 WHEN LocalPerf <= Target THEN 1 ELSE 0 END
FROM 
...


Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

sadbjp
INNER JOIN

41 Posts

Posted - 05/14/2007 :  13:50:48  Show Profile  Reply with Quote
Hi Dinakar,

it should be as follows:

If comparemethod = 1, LocalPref >= Target means GoalMet = 1.
If comparemethod = 0, then LocalPref <= Target means GoalMet = 1.
So, please tell me how can I code these stmt. in SQL?

Thanks for the help.
Go to Top of Page

dinakar
Flowing Fount of Yak Knowledge

USA
2507 Posts

Posted - 05/14/2007 :  14:10:01  Show Profile  Visit dinakar's Homepage  Reply with Quote
I have shown an example. You can take it from there. Read up books on line for more info and more samples on CASE statement.
If you are still not able to do it, post your efforts and someone can definetely help you out.

Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
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.11 seconds. Powered By: Snitz Forums 2000