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 |
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2005-11-01 : 12:38:56
|
| How can I divide two fields found within the same column. I tried the below proc. but i can't convert the 'AA' and 'BB' to a number type. Is the default for these variables varchar? Why won't my convert statements change these two values to bigint?SELECT TOTALCAP1 AS 'AA' FROM CASHBALANCEWHERE THEDAY = @THEDATE SELECT TOTALCAP1 AS 'BB' FROM CASHBALANCEWHERE THEDAY = @DATE1select (convert(bigint,'AA')/convert(bigint,'BB')) as 'rtn'Error converting data type varchar to bigint. |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2005-11-01 : 12:45:32
|
| [code]DECLARE @CAP1 as DECIMALDECLARE @CAP2 as DECIMALSELECT @CAP1 = SUM(TOTALCAP1) FROM CASHBALANCEWHERE THEDAY = @THEDATESELECT @CAP2 = SUM(TOTALCAP1) FROM CASHBALANCEWHERE THEDAY = @DATE1SELECT @CAP1 / @CAP2[/code]Help us help YOU!Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected) |
 |
|
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2005-11-01 : 15:02:19
|
| It worked perfectly.Cheers,Dirwin |
 |
|
|
|
|
|