CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 condition on mathematical calculation

Print topic Send  topic

Author Message
itzumar

Posts: 78
Posted: 02/26/2014, 5:39 AM

hi Dear all!

I have following mysql table

sr a b (a-b)
1 10 5 5
2 4 5 -1

I want its only calculate (a-b) when a is always greater than b. In other word you can say I want this output:

sr a b (a-b)
1 10 5 5
2 4 5
_________________
Umar
View profile  Send private message
eratech


Posts: 513
Posted: 02/26/2014, 9:26 PM

I find it easier to do these in the SQL - look up
CASE
statements so you have something like:

SELECT sr, a, b, (CASE WHEN (a>b) THEN (a-b) ELSE null END) as 'a-b' FROM TABLE1

E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
itzumar

Posts: 78
Posted: 02/26/2014, 9:59 PM

thanks dear :)
_________________
Umar
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.