Hi,

Someone pls correct the error.

SELECT orderid, merchant, buyprice, commission, refund, (buyprice - refund) as expenseOrder , (commission - expenseOrder )  as profitt
FROM business
WHERE merchant LIKE "GO%"

error:
MySQL said: Documentation
#1054 - Unknown column 'expenseOrder' in 'field list'

Thanks.

Replace expenseOrder with buyprice - refund

Thanks. it worked.
one more question:

SELECT orderid, merchant, buyprice, commission, refund, (
buyprice - refund - commission
) AS profitOfEchOrder
FROM business
WHERE merchant LIKE "GO%"

Above code works.
Now how can i SUM profitOfEchOrder?

Put SUM before the parenthesis.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.