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 |
|
mydadissunra
Starting Member
2 Posts |
Posted - 2009-04-16 : 08:54:10
|
| Hi, I'm trying to calculate values from a table but i want to insert different data to it.This is my query:SELECT DISTINCT Id, RFID, ToonName, ArmyName, Fraction, Unit, Picture, Weapon, WS, BS, S, T, W, I, A, Sv, COUNT(RFID) FROM sessionWHERE (Unit = @Unit)GROUP BY Weapon, ToonNameI want to count T (where unit=@unit) - S(where unit=@unit2) + 4 As WoundAny suggestions?Henrik |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-16 : 10:38:37
|
| SELECT ToonName, Weapon,COUNT(CASE WHEN unit=@unit THEN T ELSE NULL END) -COUNT(CASE WHEN unit=@unit2 THEN S ELSE NULL END) + 4 AS Wound,..FROM sessionWHERE (Unit = @Unit)GROUP BY Weapon, ToonName |
 |
|
|
mydadissunra
Starting Member
2 Posts |
Posted - 2009-04-17 : 04:51:35
|
| That didn´t work..Error:Error in SELECT clause: expression near 'END'.Error in SELECT clause: expression near 'FROM'.Missing FROM clause.Error in SELECT clause: expression near ','.Unable to parse query text.Thanks anyway.Henrik |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-17 : 10:07:50
|
| where are you using this? are you using sql server query analyser? |
 |
|
|
|
|
|
|
|