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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to code?

Author  Topic 

sadbjp
INNER JOIN

41 Posts

Posted - 2007-05-14 : 13:21:19
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
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-14 : 13:41:06
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 - 2007-05-14 : 13:50:48
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
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-14 : 14:10:01
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
   

- Advertisement -