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 |
|
tammy2512
Starting Member
8 Posts |
Posted - 2010-09-14 : 15:49:27
|
| hello,I am facing a problem with the following code:select year(regdate) as [Year],month(regdate) as [Month],CONVERT(varchar(3),regdate,100)as inmonth,count(*) as incount, cast(sum(amt)as decimal(20,2))as insum,count(case when nbr <>' ' then amt else Null end) as incountpo,SUM(case when nbr <>' ' then (amt)else 0.00 end)as insumpo,--cast( (Insumpo / InSum ) as decimal (20,4)) as sp,--CAST(incountpo/invcount)as decimal(20,4))as tpfrom invoicesgroup by year(regdate), month(regdate),CONVERT(varchar(3),regdate,100) The code is not recognizing the commented lines in the above code which is obviousCould you please help me in the above query.Thank you |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-09-14 : 15:57:22
|
| select CAST( (incountpo*1.0E/invcount)as decimal(20,4) )as tpJimP.S if incountpro and invcount are both integers, you'll see a lot of xx.0000 in your answers, that's why i miltiplied by 1.0EJimEveryday I learn something that somebody else already knew |
 |
|
|
tammy2512
Starting Member
8 Posts |
Posted - 2010-09-14 : 17:33:12
|
| thanks a lot!!! I was getting all zeroes for tp after adding your suggested change, it worked |
 |
|
|
|
|
|
|
|