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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 my query any wrong ? decimal

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2015-01-30 : 04:01:19
(trx_dat.trx_sub_disamt/nullif(trx_hdr.trx_acc_amt,0))*100 decimal(10,2) as "% per "

Run this query is error.

jleitao
Posting Yak Master

100 Posts

Posted - 2015-01-30 : 04:33:29
Can you post the error?

However, you probably have 0's in trx_acc_amd column and you are replacing them by NULLs and you can't divide by NULL



------------------------
PS - Sorry my bad english
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-01-30 : 09:17:45
quote:
Originally posted by jleitao

Can you post the error?

However, you probably have 0's in trx_acc_amd column and you are replacing them by NULLs and you can't divide by NULL



------------------------
PS - Sorry my bad english



Sure you can divide by null!

e.g.

select 1/null as 'divide by null'


returns:


divide by null
NULL
Go to Top of Page

jleitao
Posting Yak Master

100 Posts

Posted - 2015-01-30 : 09:21:11
thanks gbritton, you right :)

usafelix, can you post the error?

------------------------
PS - Sorry my bad english
Go to Top of Page

jleitao
Posting Yak Master

100 Posts

Posted - 2015-01-30 : 09:28:17


CAST((trx_dat.trx_sub_disamt/nullif(trx_hdr.trx_acc_amt,0))*100 as decimal(10,2)) as "% per"

but, post the error

------------------------
PS - Sorry my bad english
Go to Top of Page
   

- Advertisement -