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 |
|
magicman
Starting Member
6 Posts |
Posted - 2008-01-16 : 03:39:59
|
| Hi,I have created a view called vwColour from a table called tblColurs, the fieds I am interested in are Red, Blue, Orange. However the value in table tbBlue is sometimes NUll. The Calculation I am trying to perform on each row of the view is tbRed + tbBlue * tbOrange.My syntax is just adding not multiplying correctly, can you help?dbo.tblColours.Red +ISNULL(dbo.tblColours.Blue,0) * dbo.tblColours.Orange AS NewTotal.The orange value is not being calculated?red blue orange NewTotal2 4 6 6 not 12?Thanks if anyboby can help! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-16 : 03:44:10
|
quote: Originally posted by magicman Hi,I have created a view called vwColour from a table called tblColurs, the fieds I am interested in are Red, Blue, Orange. However the value in table tbBlue is sometimes NUll. The Calculation I am trying to perform on each row of the view is tbRed + tbBlue * tbOrange.My syntax is just adding not multiplying correctly, can you help?dbo.tblColours.Red +ISNULL(dbo.tblColours.Blue,0) * dbo.tblColours.Orange AS NewTotal.The orange value is not being calculated?red blue orange NewTotal2 4 6 6 not 12?Thanks if anyboby can help!
how will 2+4*6 be equal to 12?are you trying to perform 2+4+6? |
 |
|
|
magicman
Starting Member
6 Posts |
Posted - 2008-01-16 : 03:48:08
|
| No sorry, what I meant was i.eI am trying to perform 2 + 4 * 6I am getting the result as 2+4, i.e 6 not 36 which is what I want, |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-16 : 03:50:13
|
| You need to post proper sample data with expected resultMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-16 : 03:52:05
|
| Try(dbo.tblColours.Red +ISNULL(dbo.tblColours.Blue,0)) * dbo.tblColours.Orange AS NewTotal.see the difference select 2 + 4 * 6,(2 + 4) * 6MadhivananFailing to plan is Planning to fail |
 |
|
|
magicman
Starting Member
6 Posts |
Posted - 2008-01-17 : 01:50:45
|
| Voila, thx |
 |
|
|
|
|
|
|
|