Abracadabra
MIS
I need to make a calculation on an alias after performing a Case statement. One work around I tried was to perform the calculations in another stored procedure, referencing this one. This worked on a view but not on another stored procedure. Can stored procedures query other stored procedures?
Incidentally it's worth mentioning that the end result will be become a table column. I realise this is regarded as poor practice, since it breaks the rules of normalisation. However, since the calculation of gross profit on a unit of sale can only end in one result, why not store this permanently for ease of field selection in later queries? Here is part of my code(written with help from Tek-Tip members).
CASE [sale or return]
WHEN 'R'
THEN - PI.[Movement value]
ELSE PI.[movement value]
END AS value,
CASE [sale or return]
WHEN 'R'
THEN - PI.[Cost of sales]
ELSE PI.[Cost of sales]
END AS cost,
round(value-cost,2) AS profit
FROM .......
Thanks very much in advance.
Bon weekend to you all.
Peter M
Incidentally it's worth mentioning that the end result will be become a table column. I realise this is regarded as poor practice, since it breaks the rules of normalisation. However, since the calculation of gross profit on a unit of sale can only end in one result, why not store this permanently for ease of field selection in later queries? Here is part of my code(written with help from Tek-Tip members).
CASE [sale or return]
WHEN 'R'
THEN - PI.[Movement value]
ELSE PI.[movement value]
END AS value,
CASE [sale or return]
WHEN 'R'
THEN - PI.[Cost of sales]
ELSE PI.[Cost of sales]
END AS cost,
round(value-cost,2) AS profit
FROM .......
Thanks very much in advance.
Bon weekend to you all.
Peter M