| Author |
Topic |
|
Mopani
Yak Posting Veteran
55 Posts |
Posted - 2009-06-19 : 04:22:15
|
I use SQL server 2008 and VWDexpress.I am trying to write a query based on another query.In the SQL code I have the following...SELECT ID, firName, surname, Squad, batHand, bowHand, talOne, talTwo, bat, bow, tech, pow, skTalBoostFROM dbo.Squad_Full_1 What I want is to manipulate "tech" based on the value of "talOne" and "talTwo" so that it conforms to the following logic.If talOne = 4 or if talTwo = 4 then tech = tech * skTalBoost + techThanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-19 : 04:25:50
|
SELECT ID, firName, surname, Squad, batHand, bowHand, talOne, talTwo, bat, bow,case when 4 in (talone, taltwo) then tech * sktalboost + tech else tech end as tech, pow, skTalBoostFROM dbo.Squad_Full_1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Mopani
Yak Posting Veteran
55 Posts |
Posted - 2009-06-19 : 04:35:21
|
| Super Super Super !!!Thanks for the fast response. You're awesome. |
 |
|
|
Mopani
Yak Posting Veteran
55 Posts |
Posted - 2009-06-19 : 12:31:54
|
| I want to take this a step further in another query that will be based on this query, to display data that follows the following logic...I want a value called boPenal = if tagSkGapPen = 'Off' then boPenal = 0 else if bow - tech <= 1 then boPenal = 0 else ((bow - tech) - 1) * 0.5SELECT ID, firName, surname, Squad, batHand, bowHand, talOne, talTwo, bat, bow, tech, pow, skTalBoost, tagSkGapPenFROM dbo.Squad_Full_1 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-19 : 13:15:37
|
| [code]SELECT ID, firName, surname, Squad, batHand, bowHand, talOne, talTwo, bat, bow,tech,pow, skTalBoost,boPenal = case when tagSkGapPen = 'Off' then 0 when bow - tech <= 1 then 0 else ((bow - tech) - 1) * 0.5endFROM(SELECT ID, firName, surname, Squad, batHand, bowHand, talOne, talTwo, bat, bow,case when 4 in (talone, taltwo) then tech * sktalboost + tech else tech end as tech,pow, skTalBoostFROM dbo.Squad_Full_1)t[/code] |
 |
|
|
|
|
|