Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How to determine the product of values in a column?

Total Hit ( 1808)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
create table #tbltest (value numeric(3,1))
insert #tblTest values(-1.5)
insert #tblTest values(1.5)
insert #tblTest values(2.5)
insert #tblTest values(0)
select * from #tbltest

select case sum(case when sign(value) = -1 then 1 else 0 end)%2 when 1 then -1 else 1 end
   * exp(sum(log(abs(case when sign(value) <> 0 then value end))))
   * min(case when value = 0 then 0 else 1 end) as Prod1,
   case when sum(case when sign(value) = -1 then 1 end) > 0 then -1 else 1 end
   * exp(sum(log(abs(case when sign(value) <> 0 then value end))))
   * min(case when value = 0 then 0 else 1 end) as Prod2
from #tblTest

delete #tbltest where value = 0
select case sum(case when sign(value) = -1 then 1 else 0 end)%2 when 1 then -1 else 1 end
   * exp(sum(log(abs(case when sign(value) <> 0 then value end))))
   * min(case when value = 0 then 0 else 1 end) as Prod1,
   case when sum(case when sign(value) = -1 then 1 end) > 0 then -1 else 1 end
   * exp(sum(log(abs(case when sign(value) <> 0 then value end))))
   * min(case when value = 0 then 0 else 1 end) as Prod2
from #tblTest

delete #tbltest where sign(value) = -1
select case sum(case when sign(value) = -1 then 1 else 0 end)%2 when 1 then -1 else 1 end
   * exp(sum(log(abs(case when sign(value) <> 0 then value end))))
   * min(case when value = 0 then 0 else 1 end) as Prod1,
   case when sum(case when sign(value) = -1 then 1 end) > 0 then -1 else 1 end
   * exp(sum(log(abs(case when sign(value) <> 0 then value end))))
   * min(case when value = 0 then 0 else 1 end) as Prod2
from #tblTest


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.