Related to : Need to calculate when adding coin

PHP/MySQL  Calculate Profit by Adding Up Sales and Purchases then Subtracting 
You can't use alias in the same select where they are defined.
Instead, use conditional aggregation for all three:
SELECT SUM(case when salesOrPurchase = 's' then amount end) as
SalesTotal,
SUM(case when salesOrPurchase = 'p' then amount end) as
PurchasesTotal,
SUM(case when salesOrPurchase = 's' then amount
when salesOrPurchase = 'p' then  amount
end)

Automatic adding the common part to function of a class without explicitly adding those to every function 
You can define two methods that do the common logic, for example 
preProcess() and postProcess().
If the methods that execute this common logic are instnace methods of
ObjectUtils, you can even override the common methods in subclasses
of ObjectUtils if you want to alter the common logic.
If the methods that share the common logic are static methods,
preProcess() and postProcess() would also b

How to use the Computed Value to calculate another 
You have to repeat the expression
Select cost ,
(service_charge*(costDiscount)) as service_charge ,
(service_tax*(costDiscount+((service_charge*(costDiscount))*(costDiscount))))
as service_tax
From VENDOR_ITEMS WHERE vendor_items_id = 264

Calculate y derivative of image 
I think you would probably need to check out what Sobel operator does
here:
http://en.wikipedia.org/wiki/Sobel_operator

loop to calculate timestamps 
You can reset the seconds and minutes at the end of each loop :
int m = minute;
int s = second;
for (int i = hour; i < 24; i++) {
for (int j = m; j < 60; j++) {
for (int k = s; k < 60; k++) {
....
}
s = 0;
}
m = 0;
}
