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
 General SQL Server Forums
 New to SQL Server Programming
 need help with query

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 tp
from invoices
group by year(regdate), month(regdate),CONVERT(varchar(3),regdate,100)

The code is not recognizing the commented lines in the above code which is obvious

Could 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 tp

Jim

P.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.0E

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

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
Go to Top of Page
   

- Advertisement -